debug.setvalue
Alias of debug.setconstant. Global setvalue is also registered.
Syntax
debug.setvalue(func: any, index: number, value: any) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
func | any | The func value used by the call. |
index | number | A one-based index. |
value | any | The value to apply. |
Returns
| Type | Description |
|---|---|
nil | This function does not return a value. |
Description
debug.setvalue 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 value = "old"
local function f() return value end
debug.setvalue(f, 1, "new")
print(f())
Notes
- Writing protos, constants or upvalues can corrupt a running function; test changes carefully.