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.
Luau
debug.getstack(level: number, index: number?) -> any OR {[number]: any}Parameters
| Parameter | Type | Description |
|---|---|---|
level | number | Visible stack level; level 1 is the immediate caller. |
index | number? | 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
Luau
local function inspect(value)
local slots = debug.getstack(1)
print("Frame slots:", #slots, "argument:", value)
end
inspect("sample")