debug.setconstant Synchronous

  • setconstant

Replace one literal slot in a Luau prototype. This changes code that uses the slot, so save the old value if the edit should be temporary.

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

Parameters

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

Argument fields

DebugTarget fields
Luau
DebugTarget = Function | number | ProtoProxy

Returns

()

No value.

Example

Example
Luau
local function label() return "before" end
local old = debug.getconstant(label, 1)
debug.setconstant(label, 1, "after")
print(label()) -- after
debug.setconstant(label, 1, old)
Kawaii documentation