> ## 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.

# getprotos

> Returns all nested Lua functions 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.getprotos is an alias.

Returns all nested Lua functions 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.getprotos is an alias.

## Syntax

```lua theme={null}
getprotos(target: function | number): table
```

## Aliases

* `debug.getprotos`

## Arguments

| Name     | Type                 | Required | Description                                                      |
| -------- | -------------------- | -------- | ---------------------------------------------------------------- |
| `target` | `function \| number` | Yes      | Lua function or stack level whose nested functions are returned. |

## Returns

| Name     | Type    | Description                                                                     |
| -------- | ------- | ------------------------------------------------------------------------------- |
| `protos` | `table` | One-based array table containing nested functions. Empty when none are present. |

## Example

Clone every nested Proto from a Lua closure into an array of new L closures.

```lua theme={null}
local function outer()
    local function first()
        return "one"
    end

    local function second()
        return "two"
    end

    return first, second
end

local protos = getprotos(outer)

for index, proto in ipairs(protos) do
    print(index, type(proto))
end

print(#debug.getprotos(outer))
```
