compareinstances Synchronous

Compare the underlying Roblox Instance identities of two references. Use it when one reference may have come from cloneref or another wrapper-producing API.

Syntax
Luau
compareinstances(first: Instance, second: Instance) -> boolean

Parameters

Function parameters
ParameterTypeDescription
firstInstanceFirst Instance reference.
secondInstanceSecond Instance reference.

Returns

boolean

true when both references point to the same engine Instance, even if their Luau wrappers differ.

Usage notes

This is an identity comparison, not a comparison of names, classes, or property values.

Example

Example
Luau
local first = Instance.new("Folder")
local same = cloneref(first)
local different = Instance.new("Folder")
print(compareinstances(first, same)) -- true
print(compareinstances(first, different)) -- false
first:Destroy()
different:Destroy()
Kawaii documentation