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

# debug.getupvalues

Returns the upvalues captured by a closure or by a running stack frame, as a table.

```luau theme={null}
debug.getupvalues(func: function | number): {any}
```

New to upvalues? [Learn more here](/docs/notes/#upvalues).

<Note>
  Give it a number instead of a function and it reads a stack level, exactly like `debug.getupvalue`.
</Note>

Most commonly used to snapshot a closure's captured state in one call: find an unknown
function with `getgc`, dump its upvalues, and read off the objects it is holding
before touching it.

## Parameters

| Parameter | Type                                                                 | Description          |
| --------- | -------------------------------------------------------------------- | -------------------- |
| `func`    | <span style={{ whiteSpace: "nowrap" }}>`function` or `number`</span> | The closure to read. |

## Returns

`{any}` - an array-style table of the captured upvalues, in the order they were
captured. A closure with no upvalues returns an empty table, never `nil`.

## Aliases

* `getupvalues`

## Example

A closure with two upvalues, dumped with `pairs`:

<CodeGroup>
  ```luau Example 1 theme={null}
  local getupvalues = debug.getupvalues(function(...) end)
  ```

  ```luau Example 2 theme={null}
  local config = {walkspeed = 16}
  local active = true

  local function fn()
      active = not active -- assigned, so 'active' stays a real upvalue
      config.walkspeed += 1
  end

  for i, v in pairs(debug.getupvalues(fn)) do
      print(`upvalue {i}: {typeof(v)}`)
  end
  ```
</CodeGroup>

<Tip>
  Give it a number instead of a function and it reads a stack level, exactly like `debug.getupvalue`.
</Tip>
