restorefunction
Undoes hookfunction, giving a hooked function its original behavior back.
Syntax
restorefunction(func: function) -> ()
Also available as
restoreclosurerestorefuncrestore_function
Parameters
| Parameter | Type | Description |
|---|---|---|
func | function | A function previously hooked with hookfunction. |
Description
After the call every reference to func runs the original implementation again. Restoring always returns to the first implementation, even when the function was hooked several times. Copies you saved earlier with clonefunction or from hookfunction's return value keep working.
Example
local function value()
return 1
end
hookfunction(value, function() return 2 end)
print(value())
restorefunction(value)
print(value())
Notes
- Restoring a function that is not hooked raises an error, and so does restoring the same function twice.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
