Yuari
Documentation
Docs/Cache/cache.replace

cache.replace

Replaces an instance in the cache.

Syntax

cache.replace(old: any, new: any) -> nil

Parameters

ParameterTypeDescription
oldanyThe old value used by the call.
newanyThe new value used by the call.

Returns

TypeDescription
nilThis 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.