Reads the Luau registers of a live stack frame. With index you get one register; without it you get the whole frame as an array.
Every function on this page is reachable both as debug.<name> and as a plain global of the same name, so debug.getupvalues(f) and getupvalues(f) are the same call.

Parameters

thread
The thread to read. Defaults to the current one. When given, it shifts the remaining arguments along.
number
required
The stack level. 1 is your caller.
number
A single register to read, from 1. Omit it to get the whole frame.

Returns

any | table
The register, or an array of the frame’s registers.

Behavior

  • A level that does not exist returns nil, so you can probe without guarding first, while an out-of-range index raises.
  • Registers are not named locals. They are the compiler’s slots for that frame, which include temporaries.
  • Only Luau frames can be read. A C frame raises.

Example

Errors