debug.getconstants Synchronous

  • getconstants

Read all constant slots from a Luau function at once. It is useful when exploring a compiled function without guessing which slot contains a literal.

Syntax
Luau
debug.getconstants(target: DebugTarget) -> {[number]: any}

Parameters

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

Argument fields

DebugTarget fields
Luau
DebugTarget = Function | number | ProtoProxy

Returns

{[number]: any}

A table indexed by constant slot; nil constants may leave holes.

Example

Example
Luau
local function label() return "ready" end
for index, value in pairs(debug.getconstants(label)) do
    print(index, value)
end
Kawaii documentation