getfunctionreferences Synchronous

Find the tables that hold a given function, as a key or as a value. Use it to discover which module table or callback registry a function was stored in.

Syntax
Luau
getfunctionreferences(target: Function) -> {Table}

Parameters

Function parameters
ParameterTypeDescription
targetFunctionThe function to look for. Passing anything else raises an error.

Returns

{Table}

An array of live tables that contain target as a key or value.

Usage notes

Only tables are searched as holders; closures that capture the function as an upvalue are not reported. The result is a snapshot of the current VM.

Example

Example
Luau
local function onHit() end
local handlers = { hit = onHit }
for _, owner in ipairs(getfunctionreferences(onHit)) do
    print(owner == handlers)
end