cloneref Asynchronous

  • clonereference

Make a separate Luau wrapper for an existing Instance without cloning the engine object. It helps distinguish userdata identity from Instance identity when testing cache behavior.

Syntax
Luau
cloneref(instance: Instance) -> Instance

Parameters

Function parameters
ParameterTypeDescription
instanceInstanceInstance for which to create an uncached reference.

Returns

Instance

A second wrapper for the same underlying Instance. Mutations through either reference affect the same object.

Usage notes

The new wrapper does not become canonical automatically. In some native namecall hook contexts this call may yield while the original thread creates the wrapper.

Example

Example
Luau
local folder = Instance.new("Folder")
local anotherReference = cloneref(folder)
print(folder == anotherReference) -- wrapper identity can differ
print(compareinstances(folder, anotherReference)) -- true
folder.Name = "Shared object"
print(anotherReference.Name)
folder:Destroy()
Kawaii documentation