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

# restorefunction

> Restores a hooked function, or replaces one function with another when two function arguments are provided. The first argument must be a function.

<div className="real-function-page">
  ```lua theme={null}
  restorefunction(firstFunction: function, secondFunction?: function)
  ```

  ## Aliases

  * `restorefunc`
  * `restoreclosure`

  ## Arguments

  <ParamField path={"firstFunction"} type={"function"} required>
    With one argument, the hooked function to restore. With two function arguments, the function to replace.
  </ParamField>

  <ParamField path={"secondFunction"} type={"function"}>
    Optional closure to patch with firstFunction. This branch is used only when the second argument is a function.
  </ParamField>

  ## Example

  Restore a hooked closure to its original function.

  ```lua theme={null}
  local function target()
      return "original"
  end

  hookfunction(target, function()
      return "hooked"
  end)

  print(target())

  restorefunction(target)

  print(target())
  ```
</div>
