Skip to content
Functions & closuresReference

restorefunction

Represents restoration of a function's previous behavior.

Aliasesrestorefunc

Details#

Removes the hook installed on target and restores its initial behavior, including after multiple replacements. Pass the target function, not the previous implementation returned by hookfunction. Calling it again is allowed.

Signature#

Luau
restorefunction(target: function): boolean

Parameters#

ParameterTypeDescription
targetfunctionThe exact function value to inspect or modify.

Returns#

true when restored; false if target has no saved hook.

Examples#

Example

Luau
local function value() return 1 end
hookfunction(value, function() return 2 end)
print(value()) -- 2
print(restorefunction(value)) -- true
print(value()) -- 1
print(restorefunction(value)) -- false