Functions
Closures, hooks, prototypes, and garbage-collector inspection.
Functions
clonefunctionCreate a separate callable from an existing function. A clone is useful when you want a callable copy before changing the original with a hook.
comparefunctionsCompare two functions by their underlying callable definition and captured references rather than by table-style identity alone. This helps check whether a wrapper or clone still represents the same behavior.
filtergcSearch the current VM’s live functions or tables using fields that matter to you, rather than scanning every getgc result by hand. It is useful for finding a table with known keys or a Luau closure with a known hash.
getfunctionbytecodeSerialize a Luau function’s compiled prototype to a byte string. Use this when a tool needs the actual compiled bytes rather than a readable source listing.
getfunctionhashCompute a stable digest from a Luau function’s prototype. It is handy when comparing compiled code across separate closure instances without relying on their addresses.
getgcTake a snapshot of live garbage-collected values in the current VM. It is useful for inspection tools that need to locate closures, userdata, or optionally tables.
hookfunctionReplace calls to a function and return a callable for the preceding implementation. An optional filter limits which calls reach the replacement.
hookmetamethodReplace a callable metamethod on an object and return its preceding implementation. An optional fifth argument filters calls before they reach the replacement.
hookprotoReplace a nested Luau prototype so calls to closures created from it use replacement code. Use this for a specific nested function obtained with debug.getproto, and restore it after the inspection or experiment.
iscclosureTell whether a function is a native C closure. This is useful before using debug operations that only work on Luau closures.
isexecutorclosureCheck whether a closure belongs to Kawaii’s execution environment. This can distinguish a function created by your script from a game-owned function during inspection.
isfunctionhookedCheck whether a function currently has a live hook. Use it before restoring a hook when the same cleanup path may run twice.
islclosureTell whether a function is a Luau closure. Check this before reading or changing its constants or nested prototypes.
isnewcclosureIdentify a wrapper created by newcclosure. It is narrower than iscclosure: an ordinary native C function is not necessarily one of these wrappers.
isprotohookedSee whether a ProtoProxy currently has a replacement installed by hookproto. This is useful for idempotent cleanup of nested function patches.
newcclosureWrap a callback in a C closure while forwarding its arguments and results. This is useful when an API requires a C closure but your behavior is written in Luau.
newlclosureCreate a Luau forwarding closure around another function. Use it when you need a distinct Luau callable while keeping the original function’s behavior.
restorefunctionRemove an installed function hook and return calls to the preceding implementation. Call it during cleanup so a temporary observation or override does not outlive your script.
restoreprotoUndo a hookproto replacement for a specific ProtoProxy. It restores the original nested code for closures that were affected by that hook.
trampoline_callCall a function while supplying a synthetic call stack and optional execution context. This is for diagnostic or compatibility work that must control what the callback sees as its caller.