Skip to content
Saiko

debug.getproto

Returns a function nested inside another. Pass active to get the live closures instead of the prototype.

Signature

luau
debug.getproto(fn: function | number, index: number, active: boolean?): function | { function }

Parameters

fnfunction | number

The parent function.

indexnumber

1-based prototype index.

activeboolean?

Return live closures rather than the prototype.

Returns

function

Example

luau
local function outer()
    local function inner()
        return "inside"
    end
    return inner
end

local inner = debug.getproto(outer, 1, true)[1]
print(inner()) --> inside