hookfunction,
hookmetamethod, or
getfilter, and the test runs in C++ against the live call.
Calls that do not match never enter your Luau hook at all.
That matters most for __namecall. A plain __namecall hook runs Luau for every
method call in the game — thousands per second. With a filter, the common case is
a native comparison and a direct forward to the original.
Why use one
Less overhead
Non-matching calls are rejected natively and forwarded straight through,
without building a Luau frame.
Simpler hooks
No
if getnamecallmethod() ~= "..." then return old(...) end preamble. The
hook body only ever sees the calls you asked for.Classes
Every filter is created with.new and is immutable in shape but mutable in its
properties — assigning a property changes matching immediately, including for a
hook that is already installed.
Functions
Argument indices
index counts the arguments of the call being filtered, starting at 1. For a
__namecall hook the object the method was called on is argument 1, so the
first real parameter is 2:
nil rather than failing, so
TypeFilter.new(3, "nil") is a valid way to require “no third argument”.
Composing
Filters nest, so you can build exactly the predicate you want:AnyFilter with no entries never matches; AllFilter with no entries always
matches. Nesting is bounded, and a filter that contains itself simply fails to
match rather than hanging.
Live changes
Properties are writable and take effect on the next call, even for a hook that is already running:Type
Each class reports its own name throughtypeof, and the metatable is locked: