debug.getprotos Synchronous

  • getprotos

List the immediate nested prototypes compiled inside a Luau function. This helps you locate a child function before asking for its metadata or installing a proto hook.

Syntax
Luau
debug.getprotos(target: DebugTarget) -> {ProtoProxy}

Parameters

Function parameters
ParameterTypeDescription
targetDebugTargetA Luau function, visible stack level, or ProtoProxy. Indexes in these APIs start at 1.

Argument fields

DebugTarget fields
Luau
DebugTarget = Function | number | ProtoProxy

Returns

{ProtoProxy}

An array of ProtoProxy objects in prototype order.

Example

Example
Luau
local function factory()
    local function first() end
    local function second() end
    return first, second
end
for index, proto in ipairs(debug.getprotos(factory)) do
    print(index, debug.getinfo(proto).source)
end
Kawaii documentation