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

# restorefunction

Reverses `hookfunction` - the target goes back to running its original body.

```luau theme={null}
restorefunction(func: function): ()
```

Pass the function you hooked and it stops running the hook. If the same function was hooked more than once, one `restorefunction` call still reverts it to the very first original. After it runs, `isfunctionhooked` reports `false` for that function.

Throws an error if the function you passed was never hooked.

## Parameters

| Parameter | Type       | Description                     |
| --------- | ---------- | ------------------------------- |
| `func`    | `function` | The hooked function to restore. |

## Returns

<code title="the function does not return a value.">void</code>

## Aliases

* `restorefunc`

## Example

Hook a function only while you need it, then put it back so the rest of the game keeps seeing the real one.

<CodeGroup>
  ```luau Example 1 theme={null}
  <<<<<<< HEAD
  restorefunction(print)
  =======
  -- restorefunction(func: function): ()
  >>>>>>> 50e30f53759b0538759af25c9b271514aa2c9290
  ```

  ```luau Example 2 theme={null}
  local function greet(name)
      return `hello {name}`
  end

  local original = hookfunction(greet, function(name)
      return `hooked {name}`
  end)

  print(greet("world"))                  --> hooked world
  print(isfunctionhooked(greet))         --> true

  restorefunction(greet)

  print(greet("world"))                  --> hello world
  print(isfunctionhooked(greet))         --> false

  -- `original` still points at the pre-hook body if you kept it
  print(original("world"))               --> hello world
  ```
</CodeGroup>

<Tip>
  Cleans up memory hook state and resets the function pointers.
</Tip>
