cloneref
Creates a new reference to an instance that compares as different.
Syntax
cloneref(instance: Instance) -> InstanceAliases
clonereference
Parameters
| Parameter | Type | Description |
|---|---|---|
instance | Instance | The instance to clone a reference to |
Returns
| Type | Description |
|---|---|
Instance | A new reference to the same instance |
Description
cloneref creates a new reference to an instance. The cloned reference points to the same underlying object, but the two references are not equal when compared with ==.
Example
local folder = Instance.new("Folder")
folder.Name = "Original"
local clone = cloneref(folder)
-- Both reference the same instance
print(folder.Name) -- "Original"
print(clone.Name) -- "Original"
-- But they compare as different
print(folder == clone) -- false
-- Changes through one affect the other
clone.Name = "Renamed"
print(folder.Name) -- "Renamed"Verification
-- Verify they're the same underlying instance
print(compareinstances(folder, clone)) -- trueRelated Functions
compareinstances- Compare two references