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

Returns the inner function at `index` inside a Luau function.

```luau theme={null}
debug.getproto(func: function | level: number, index: number, activated: boolean?): function | {function}
```

<Tip>
  When you want an inner function you can call, use `activated` `true` and take the first entry: `debug.getproto(f, i, true)[1]`. This is the reliable way to get a callable proto.
</Tip>

## Parameters

| Parameter   | Type                                                               | Description                                                                                           |
| ----------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| `func`      | <span style={{ whiteSpace: "nowrap" }}>`function \| number`</span> | The parent function, or a stack level pointing at the running closure to read protos from.            |
| `index`     | `number`                                                           | Which proto to return, 1-based.                                                                       |
| `activated` | `boolean?`                                                         | `true` returns a table of the proto's live closures instead of the proto itself. Defaults to `false`. |

## Returns

With `activated` left out or `false`, returns the single proto function sitting at `index`.

With `activated` set to `true`, returns a table of that proto's closures. Index it with `[1]` to get an inner function you can call straight away.

## Aliases

* `getproto`

## Example

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

  ```luau Example 2 theme={null}
  local mainfn = getscriptclosure(targetScript)
  local inner = debug.getproto(mainfn, 1, true)[1]
  print(`first proto: {tostring(inner)}`)
  ```
</CodeGroup>

<Tip>
  When you want an inner function you can call, use `activated` `true` and take the first entry: `debug.getproto(f, i, true)[1]`. This is the reliable way to get a callable proto.
</Tip>
