getobjectreferences Synchronous

Find the tables that hold a given table, as a key or as a value. It answers “what is keeping this table reachable?” when you track down where a game stores some state.

Syntax
Luau
getobjectreferences(target: Table) -> {Table}

Parameters

Function parameters
ParameterTypeDescription
targetTableThe table to look for. Passing anything else raises an error.

Returns

{Table}

An array of the other live tables that contain target as a key or value. The target itself is not included.

Usage notes

Only tables are searched as holders; a closure that captures the table as an upvalue is not reported. The result is a snapshot of the current VM.

Example

Example
Luau
local state = { coins = 10 }
local holder = { current = state }
for _, owner in ipairs(getobjectreferences(state)) do
    print(owner == holder)
end