debug.getstack Synchronous

  • getstack

Read the register values of a visible Luau stack frame. It helps diagnose an active call when you need its current values, not just the function’s compiled metadata.

Syntax
Luau
debug.getstack(level: number, index: number?) -> any OR {[number]: any}

Parameters

Function parameters
ParameterTypeDescription
levelnumberVisible stack level; level 1 is the immediate caller.
indexnumber?Optional one-based register slot. Omit it for all slots.

Returns

any OR {[number]: any}

One register value when index is supplied; otherwise a table of frame slots.

Usage notes

Stack slot positions are implementation details; inspect a frame before assuming an index has a particular local variable.

Example

Example
Luau
local function inspect(value)
    local slots = debug.getstack(1)
    print("Frame slots:", #slots, "argument:", value)
end
inspect("sample")
Kawaii documentation