> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# getupvalues

> Returns all upvalues from a Lua function or stack level as a one-based array table. Invalid stack levels raise "Level out of range", and non-Lua functions raise "Lua function expected". debug.getupvalues is an alias.

<div className="real-function-page">
  ```lua theme={null}
  getupvalues(target: function | number): table
  ```

  ## Aliases

  * `debug.getupvalues`

  ## Argumentos

  <ParamField path={"target"} type={"function | number"} required>
    Lua function or stack level whose upvalues are returned.
  </ParamField>

  ## Retornos

  <ResponseField name={"upvalues"} type={"table"}>
    One-based array table containing the function upvalues. Empty when none are present.
  </ResponseField>

  ## Exemplo

  Read all upvalues from a Lua closure or stack level.

  ```lua theme={null}
  local first = "one"
  local second = "two"

  local function target()
      return first, second
  end

  local upvalues = getupvalues(target)

  for index, value in ipairs(upvalues) do
      print(index, value)
  end

  print(#debug.getupvalues(target))
  ```
</div>
