debug.getconstant
Reads one function constant.
Syntax
Signature
debug.getconstant(FunctionOrLevel: function | number, Index: number) -> anyAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
FunctionOrLevel | function | number | Luau closure or positive stack level. |
Index | number | One-based constant slot. |
Returns
| Type | Description |
|---|---|
any | The constant at Index. |
Notes
Indexes start at 1. Nil, table, and function constants are returned as nil. An invalid index raises an error.
Example
Luau
local Function = function() local Message = "Hello" return Message end
local Result = debug.getconstant(Function, 1)
print(Result)