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.

Syntax
Luau
cache.replace(instance: Instance, replacement: Instance) -> ()

Parameters

Function parameters
ParameterTypeDescription
instanceInstanceInstance identifying the engine object whose cache entry changes.
replacementInstanceInstance 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

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()
Kawaii documentation