Cache

Mess with World's instance reference cache. Swap one reference for another, drop entries, or check if an instance is tracked.

Overview

The client keeps a cache that maps engine instances to the Luau values scripts get. Changing that cache changes what every script in the game gets back for that instance, including the game's own scripts.

Swapping a reference
local part = workspace:FindFirstChildWhichIsA("BasePart")
local decoy = part:Clone()

-- Everyone who looks this part up now gets the decoy.
cache.replace(part, decoy)

print(cache.iscached(part))
cache.invalidate(part)      -- drop it and let it be re-cached fresh

This affects everything

A cache replacement isn't just for your script. Every script in the game sees it, which is powerful and easy to mess up. cache.invalidate undoes it.

Cache table