VINDICTA
Closures · Function
Bunni.fun
ChocoSploit
Cryptic
Potassium
Seliware
SirHurt
Solara
Velocity
Volcano
Volt
Wave
Xeno

restorefunction

Restore a hooked function back to its very first original implementation.

function restorefunction(func: (...any) -> (...any)): ()

Synopsis

How it works

Reverts a hooked function to its original state. For Luau closures, it restores the original Proto pointer and upvaluesUpvalueA variable captured from an enclosing scope. When a function references a local variable from an outer function, that variable becomes an upvalue — stored in an UpVal struct that persists even after the outer function returns.. For C closures, it restores the original C function pointer. This undoes changes made by hookfunction().

Limitations

Only works on functions that were hooked through the executor’s hookfunction() API, which stores the original internally. If a function was modified through other means (direct bytecodeBytecodeThe compiled binary representation of Luau source code. A sequence of 32-bit instructions (opcodes + operands) stored in a Proto's code[] array. Executed by the Luau VM interpreter. patching), restorefunction may not have the original to restore.

Usage

Hook and then restore a function
function dummy()
    print("Original")
end

hookfunction(dummy, function()
    print("Hooked!")
end)

dummy()           "cc">-- Output: Hooked!
restorefunction(dummy)
dummy()           "cc">-- Output: Original
Error on unhooked function
restorefunction(print) "cc">-- Error: restorefunction: function is not hooked

Parameters

func function
The hooked function to restore to its original state.
Must be hooked first
Calling restorefunction on a function that is not hooked throws an error. Check with hookfunction return value before calling.