cloneref
Creates a new reference to an instance that compares as different.
Syntax
cloneref(instance: Instance) -> InstanceParameters
| 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 part = workspace.Part
local clone = cloneref(part)
-- Both reference the same instance
print(part.Name) -- "Part"
print(clone.Name) -- "Part"
-- But they compare as different
print(part == clone) -- false
-- Changes through one affect the other
clone.Name = "Renamed"
print(part.Name) -- "Renamed"Use Cases
- Anti-detection: Prevent games from detecting your references
- Reference hiding: Create references that can't be found through equality checks
Verification
-- Verify they're the same underlying instance
print(compareinstances(part, clone)) -- trueRelated Functions
compareinstances- Compare two references