Yuari
Documentation
Docs/Debug/debug.setconstant

debug.setconstant

Writes a constant. Global: setconstant.

Syntax

debug.setconstant(func: any, index: number, value: any) -> nil

Parameters

ParameterTypeDescription
funcanyThe func value used by the call.
indexnumberA one-based index.
valueanyThe value to apply.

Returns

TypeDescription
nilThis function does not return a value.

Description

debug.setconstant 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 change is applied directly to the live target, so later reads observe the updated value.

Example

local function f() return 123 end
debug.setconstant(f, 1, 456)
print(f())

Notes

  • Writing protos, constants or upvalues can corrupt a running function; test changes carefully.