Cache

compareinstances

Compares the Instance references stored in two Instance object values.

Syntax

compareinstances(first: Instance, second: Instance): boolean

Arguments

NameTypeDescription
firstInstanceFirst Instance object to compare.
secondInstanceSecond Instance object to compare.

Returns

NameTypeDescription
equalbooleanTrue when both Instance object values contain the same underlying reference.

Description

Compares the Instance references stored in two Instance object values.

Call it with 2 parameter(s): first, second. The argument table explains which values are required and which ones only refine the behavior.

It returns equal (boolean). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Compare the underlying Instance references.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

print(compareinstances(Players, Players))
print(compareinstances(Players, ReplicatedStorage))