cache. replace Synchronous
syn.cache_replace
Choose which Instance wrapper becomes canonical for an engine object. Use it when code must make a cloned wrapper the one returned by later ObjectBridge lookups.
Luau
cache.replace(instance: Instance, replacement: Instance) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
instance | Instance | Instance identifying the engine object whose cache entry changes. |
replacement | Instance | Instance wrapper to store as the new canonical value. |
Returns
()No values.
Usage notes
This changes wrapper caching, not the Instance’s properties or parent. A replacement must be an Instance.
Example
Luau
local part = Instance.new("Part")
local clone = cloneref(part)
cache.replace(part, clone)
print(cache.iscached(clone)) -- true
print(compareinstances(part, clone)) -- true
cache.replace(part, part)
part:Destroy()