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

Sets the name of the specified function in the debug structure.

```luau theme={null}
debug.setname(func: function, name: string): ()
```

## Parameters

| Parameter | Type       | Description                          |
| --------- | ---------- | ------------------------------------ |
| `func`    | `function` | The target function to rename.       |
| `name`    | `string`   | The new debug name for the function. |

## Returns

`void`

## Example

<CodeGroup>
  ```luau Example 1 theme={null}
  local function test() end
  debug.setname(test, "new_func_name")
  print(debug.getinfo(test).name) -- "new_func_name"
  ```

  ```luau Example 2 theme={null}
  debug.setname(function() end, "anonymous_hook")
  ```
</CodeGroup>

<Tip>
  Renaming functions makes stack traces and profiling outputs easier to read.
</Tip>
