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

# isfunctionhooked

Tells you whether a function is currently hooked.

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

`hookfunction` hooks a function and `restorefunction` puts it back. `isfunctionhooked` only reports the current state - it never hooks or restores anything itself.

## Parameters

| Parameter | Type       | Description            |
| --------- | ---------- | ---------------------- |
| `func`    | `function` | The function to check. |

## Returns

`true` if `func` is currently under a `hookfunction` hook, `false` if it never was or has since been restored with `restorefunction`.

## Example

The common use is a guard: check `isfunctionhooked` before `hookfunction` so you never double-hook the same function. This run also shows the flag flipping back after `restorefunction`:

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

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

  print(isfunctionhooked(greet)) -- false, nothing has hooked it yet

  if not isfunctionhooked(greet) then
      local original = hookfunction(greet, function(...)
          print("hooked")
          return original(...)
      end)
  end

  print(isfunctionhooked(greet)) -- true

  restorefunction(greet)
  print(isfunctionhooked(greet)) -- false again, back to the original body
  ```
</CodeGroup>

<Tip>
  Checks internal executor state to see if a hook is active on the function.
</Tip>
