debug.getproto Synchronous

  • getproto

Get one nested Luau prototype from a function. Use the default ProtoProxy for metadata or prototype hooks; request active closures when you need actual live functions.

Syntax
Luau
debug.getproto(
    target: DebugTarget,
    index: number,
    active: boolean?
) -> ProtoProxy OR {Function}

Parameters

Function parameters
ParameterTypeDescription
targetDebugTargetA Luau function, visible stack level, or ProtoProxy. Indexes in these APIs start at 1.
indexnumberOne-based nested prototype slot.
activeboolean?Optional boolean. true searches for active closures made from that prototype.

Argument fields

DebugTarget fields
Luau
DebugTarget = Function | number | ProtoProxy

Returns

ProtoProxy OR {Function}

A ProtoProxy by default; with active=true, an array of matching live functions.

Usage notes

An active search can return an empty array if no matching closure is live.

Example

Example
Luau
local function factory()
    return function() return "inside" end
end
local nested = debug.getproto(factory, 1)
print(debug.getinfo(nested).source)
Kawaii documentation