| title | cache.replace |
|---|
Swaps a cached Instance with another so every existing reference to it resolves to the replacement.
cache.replace(old: Instance, new: Instance): ()After the call, any script still holding old is really working with new - reading old.Name returns new.Name, and print(old) shows new. The old Instance is no longer reachable through the cache.
Most commonly used to hide a watched Instance from anti-cheat scanners: swap the real object for a harmless decoy so game scripts that re-resolve it through the cache get the decoy, while your code keeps the real one with cloneref.
| Parameter | Type | Description |
|---|---|---|
old |
Instance |
The cached Instance to repoint. |
new |
Instance |
The Instance its references now resolve to. |
void
cache.replace(game:GetService("Players"), game:GetService("Players"))local watched = game:GetService("ReplicatedStorage").Remotes.Combat
local real = cloneref(watched) -- private handle to the genuine RemoteEvent
-- the game re-resolves this through the cache and lands on the decoy instead
cache.replace(watched, Instance.new("RemoteEvent"))
real:FireServer("attack") -- still reaches the real remote