cache.replace
Replaces an instance in the cache.
Syntax
cache.replace(old: any, new: any) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
old | any | The old value used by the call. |
new | any | The new value used by the call. |
Returns
| Type | Description |
|---|---|
nil | This function does not return a value. |
Description
cache.replace is part of the Cache library. The module keeps a stable instance cache so userdata survives Roblox object churn. Cache calls inspect or change that mapping without modifying the game object itself.
The change is applied directly to the live target, so later reads observe the updated value.
Example
local old = Instance.new("Part")
local newPart = Instance.new("Part")
cache.replace(old, newPart)
Notes
- Cache changes affect future lookups; existing userdata references remain valid.