Volt

cache.replace

Replaces a cached instance reference with another.

Syntax

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

Parameters

ParameterTypeDescription
instanceInstanceThe instance to replace
replacementInstanceThe replacement instance

Returns

This function does not return a value.

Description

cache.replace replaces a cached instance reference with another instance. All existing references to the original instance will now point to the replacement.

Example

local original = workspace.Part
local replacement = Instance.new("Part")
replacement.Name = "FakePart"

-- Replace the cached reference
cache.replace(original, replacement)

-- Now any access to the original returns the replacement
print(workspace.Part.Name) -- "FakePart"

Notes

  • Use with caution as this affects all references
  • The original instance still exists

On this page