ReferenceDebug

getobjectreferences

Finds what still refers to a value.

Syntax

getobjectreferences(object: any) -> {any}

Parameters

ParameterTypeDescription
objectanyThe value to look for.

Returns

TypeDescription
{any}Tables that hold the value and Luau closures that capture it.

Description

Walks every object the collector holds. A table is listed when the value is one of its keys, one of its values or its metatable; a Luau closure is listed when the value is one of its upvalues. The result is a snapshot, and the list itself is never part of it.

Example

local box = {held = {}}
for _, owner in getobjectreferences(box.held) do
    print(owner == box)
end

These are Game executor contracts. Check build requirements and session lifetimes before using them.