Skip to content

cloneref

Creates a safe reference to protected instances

cloneref returns a reference to an Instance. This can help avoid weak table styled detections.

cloneref returns a reference clone of an Instance. The returned object behaves identically to the original but is not strictly equal (==) to it.

This is commonly used to safely interact with services such as game.CoreGui, making weak-table style attacks fail.

function cloneref<T>(object: T & Instance): T

Parameters

Parameter Description
object The Instance to clone a safe reference from.

Example

Cloning a safe reference to LocalPlayer
1
2
3
4
5
6
7
local players = game:GetService("Players")

local original = players.LocalPlayer
local clone = cloneref(original)

print(original == clone) -- Output: false
print(clone.Name)        -- Output: Player's name (same as original)