Yuari
Documentation
Docs/Debug/debug.getupvalue

debug.getupvalue

Reads upvalues. Globals: getupvalue / getupvalues.

Syntax

debug.getupvalue(func: any, index: number) -> any

Parameters

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

Returns

TypeDescription
anyThe value produced by the call.

Description

debug.getupvalue 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 call is read-only: it resolves the current value when invoked and does not change the underlying state.

The aliases debug.getupvalues(func) resolve to the same implementation.

Example

local value = 10
local function f() return value end
print(debug.getupvalue(f, 1))
print(#debug.getupvalues(f))

Notes

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