oth.unhook Synchronous

Remove one OTH hook layer from a target. Select a specific layer when several callbacks have been installed.

Syntax
Luau
oth.unhook(target: Function, selector: Function?) -> boolean

Parameters

Function parameters
ParameterTypeDescription
targetFunctionThe C closure originally passed to oth.hook.
selectorFunction?Optional returned callable or callback function identifying the layer. Omit it only when exactly one active layer remains.

Returns

boolean

true when a layer was removed; false when no matching target or selector was found.

Usage notes

With multiple active layers, omitting the selector raises an error without changing the chain. A callback function selects its most recently installed active registration.

Removing the last layer restores the target. A call already in progress can finish using its saved callback context.

Example

Example
Luau
local target = newcclosure(function(value) return value end)
local first = oth.hook(target, function(value) return value .. "!" end)
local second = oth.hook(target, function(value) return value .. "?" end)
print(oth.unhook(target, second)) -- true: remove second layer
print(oth.unhook(target, first))  -- true: restore target
Kawaii documentation