filtergc Synchronous

Search 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.

Syntax
Luau
filtergc(
    kind: "function" | "table",
    options: GcFilterOptions,
    returnOne: boolean?
) -> {Function | Table} OR Function OR Table OR nil

Parameters

Function parameters
ParameterTypeDescription
kind"function" | "table"Either "function" or "table".
optionsGcFilterOptionsFor functions: Name, Hash, Constants, Upvalues, IgnoreExecutor. For tables: Keys, Values, KeyValuePairs, Metatable.
returnOneboolean?true returns the first match or nil; omitted or false returns all matches.

Argument fields

GcFilterOptions fields
Luau
GcFilterOptions = {
  IgnoreExecutor: boolean?, Name: string?, Hash: string?,
  Constants: Table?, Upvalues: Table?, Keys: Table?, Values: Table?,
  KeyValuePairs: Table?, Metatable: Table?
}

Returns

{Function | Table} OR Function OR Table OR nil

An array of matches by default; one matching value or nil when returnOne is true.

Usage notes

Function searches ignore executor-owned functions by default; set IgnoreExecutor = false to include them. Search results are a snapshot, and first-match order is unspecified.

Example

Example
Luau
local marker = { docsExample = true }
local found = filtergc("table", { KeyValuePairs = { docsExample = true } }, true)
print(found ~= nil)
marker.docsExample = false
Kawaii documentation