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

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

  ## Aliases

  * `debug.getprotos`

  ## Argumentos

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

  ## Retornos

  <ResponseField name={"protos"} type={"table"}>
    One-based array table containing nested functions. Empty when none are present.
  </ResponseField>

  ## Exemplo

  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))
  ```
</div>
