debug.getstack
Reads register slots from a live Luau stack frame.
Syntax
Signature
debug.getstack(Level: number, Index: number?) -> anyAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
Level | number | Positive stack level selecting a live Luau frame. |
Index | number? | One-based slot to read. Omit to read all slots. |
Returns
| Type | Description |
|---|---|
any | Selected slot value, or a table of slot values when Index is omitted. |
Notes
Level 1 selects the calling frame. With Index omitted, returns the frame's slots in a one-based table. With Index supplied, returns just that slot. These slots are VM registers rather than a list of named local variables.
Example
Luau
local function Example()
local Message = "Hello"
print(debug.getstack(1))
return Message
end
Example()