Yuari
Documentation
Docs/Debug/debug.setupvalue

debug.setupvalue

Writes an upvalue. Global: setupvalue.

Syntax

debug.setupvalue(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.setupvalue 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.

The aliases setupval(func, index, value) resolve to the same implementation.

Example

local value = 10
local function f() return value end
debug.setupvalue(f, 1, 99)
print(f())

Notes

  • Aliases: setupval(func, index, value).
  • Writing protos, constants or upvalues can corrupt a running function; test changes carefully.