debug. getconstant Synchronous
getconstant
Read one constant stored in a Luau function’s compiled prototype. Use it when inspecting the literal values a function was compiled with.
Luau
debug.getconstant(target: DebugTarget, index: number) -> anyParameters
| Parameter | Type | Description |
|---|---|---|
target | DebugTarget | A Luau function, visible stack level, or ProtoProxy. Indexes in these APIs start at 1. |
index | number | One-based constant slot. |
Argument fields
Luau
DebugTarget = Function | number | ProtoProxyReturns
anyThe value in that constant slot.
Usage notes
Invalid indexes and C closure targets raise an error.
Example
Luau
local function label() return "ready" end
print(debug.getconstant(label, 1)) -- ready