gethook
Returns the replacement function installed on a hooked function.
Syntax
gethook(target: any) -> function
Parameters
| Parameter | Type | Description |
|---|---|---|
target | any | Function previously passed to hookfunction. |
Returns
| Type | Description |
|---|---|
function | The replacement function installed on the target, or nil. |
Description
gethook looks up the live hook record for a function and returns the replacement closure that receives matching calls.
If the function is not hooked, the result is nil. The original behavior can still be obtained through the value returned by hookfunction.
Example
local original = hookfunction(print, function(...) end)
print(gethook(print) ~= nil) -- true
restorefunction(print)
Notes
- Closure operations act on live Luau function objects; installed hooks remain active until restored.
- Returns the hook, not the original function.