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.

Syntax
Luau
debug.getconstant(target: DebugTarget, index: number) -> any

Parameters

Function parameters
ParameterTypeDescription
targetDebugTargetA Luau function, visible stack level, or ProtoProxy. Indexes in these APIs start at 1.
indexnumberOne-based constant slot.

Argument fields

DebugTarget fields
Luau
DebugTarget = Function | number | ProtoProxy

Returns

any

The value in that constant slot.

Usage notes

Invalid indexes and C closure targets raise an error.

Example

Example
Luau
local function label() return "ready" end
print(debug.getconstant(label, 1)) -- ready
Kawaii documentation