Skip to main content
Returns the upvalue at a given index in a closure or a running stack frame.
New to upvalues? Learn more here.
Give it a number instead of a function and the number is treated as a stack level - 0 is the call running right now, 1 its caller, and so on - and the upvalue comes from whatever closure is running there.
Most commonly used while reversing a game script: grab a closure with getgc and read its upvalues to see the state it holds before deciding whether to read, change, or hook it.

Parameters

Returns

any - whatever the closure stored at that slot. The type is not fixed: a table, an Instance, a function, and so on.

Aliases

  • getupvalue

Example

A closure that captures a table, read straight back out by index:
Give it a number instead of a function and the number is treated as a stack level - 0 is the call running right now, 1 its caller, and so on - and the upvalue comes from whatever closure is running there.