AllFilter.new Synchronous

Match a hooked call only when every child filter matches. Use it when several conditions must hold together, such as a particular argument value and Instance class.

Syntax
Luau
AllFilter.new(filters: {HookFilter}) -> HookFilter

Parameters

Function parameters
ParameterTypeDescription
filters{HookFilter}An array of HookFilter objects. Every visited child must match; an empty array matches every call.

Returns

HookFilter

A 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

Example
Luau
local target = newcclosure(function(label, amount) return amount end)
local filter = AllFilter.new({
    ArgumentFilter.new(1, "preview"),
    ArgumentFilter.new(2, 5),
})
local previous
previous = hookfunction(target, function(label, amount)
    return previous(label, amount) + 1
end, filter)
print(target("preview", 5)) -- 6: both conditions matched
print(target("final", 5))   -- 5: the original handled this call
restorefunction(target)
Kawaii documentation