debug.getconstant
Reads function constants. Globals: getconstant / getconstants.
Syntax
debug.getconstant(func: any, index: number) -> any
Parameters
| Parameter | Type | Description |
|---|---|---|
func | any | The func value used by the call. |
index | number | A one-based index. |
Returns
| Type | Description |
|---|---|
any | The value produced by the call. |
Description
debug.getconstant is part of the Debug library. The debug library exposes the internals of the active Luau state, including protos, constants, upvalues and stack frames.
The call is read-only: it resolves the current value when invoked and does not change the underlying state.
The aliases debug.getconstants(func) resolve to the same implementation.
Example
local function f() return 123 end
print(debug.getconstant(f, 1))
print(#debug.getconstants(f))
Notes
- Aliases:
debug.getconstants(func). - Writing protos, constants or upvalues can corrupt a running function; test changes carefully.