NotFilter. new Synchronous
Match when one valid child filter does not match. Use it to exclude a specific value or condition from a broader hook.
Luau
NotFilter.new(filter: HookFilter) -> HookFilterParameters
| Parameter | Type | Description |
|---|---|---|
filter | HookFilter | A HookFilter to invert. A child that is invalid during evaluation does not become a match by being negated. |
Returns
HookFilterA HookFilter table to pass as the optional filter argument of hookfunction, hookmetamethod, or oth.hook. It does not run until a hooked call is evaluated.
Usage notes
A match calls the replacement. A miss continues through the preceding hook or original function. Omit the filter or pass nil to handle every call.
Compound filters short-circuit. A visited invalid or cyclic child fails the match, including inside NotFilter. Evaluation supports at most 64 nested levels and 256 children in one compound filter; exceeding a limit fails the match.
Example
Luau
local target = newcclosure(function(value) return value end)
local filter = NotFilter.new(ArgumentFilter.new(1, "skip"))
local previous
previous = hookfunction(target, function(value)
return "seen: " .. previous(value)
end, filter)
print(target("ready")) -- seen: ready
print(target("skip")) -- skip
restorefunction(target)