Query
Selects Instances by components, tags, class, hierarchy, and component changes.
Behavior
Query selects Instances by components, tags, class, hierarchy, and component changes.
Summary
Query.new(args: ...Component | string): QueryCreates a reusable query requiring each listed component.
Returns a new query filtered to Instances whose specified component was added during the current change-tracking frame.
Returns a new query filtered to Instances whose specified component changed during the current change-tracking frame.
collect(): tableReturns a new array of matching Instances.
count(): numberReturns the number of Instances matching the current query filters.
first(): (Instance?, ...ComponentHandle)Returns the first matching Instance and its component handles.
isA(className: string): QueryReturns a new query restricted to the named class and its subclasses.
removed(): table, booleanReturns Instances that lost one of the query's required components since the previous call, followed by a completeness boolean.
Returns a new query requiring an ancestor carrying the specified component.
Returns a new query with additional required components or tags.
Returns a new query restricted to descendants of the supplied Instance.
Returns a new query excluding Instances with any listed component or tag.
Constructors
new
Query.new(args: ...Component | string): QueryCreates a reusable query requiring each listed component. Terms accept Component definitions or component names. An unresolved required component produces no matches until it becomes available. Iteration returns the Instance followed by handles in term order.
Methods
added
Query:added(component: Component | string): QueryReturns a new query filtered to Instances whose specified component was added during the current change-tracking frame.
changed
Query:changed(component: Component | string): QueryReturns a new query filtered to Instances whose specified component changed during the current change-tracking frame.
collect
Query:collect(): tableReturns a new array of matching Instances. Component handles are not included.
count
Query:count(): numberReturns the number of Instances matching the current query filters.
first
Query:first(): (Instance?, ...ComponentHandle)Returns the first matching Instance and its component handles. Returns nil when no Instance matches. Do not depend on iteration order.
isA
Query:isA(className: string): QueryReturns a new query restricted to the named class and its subclasses. An unknown class name causes an error.
removed
Query:removed(): table, booleanReturns Instances that lost one of the query's required components since the previous call, followed by a completeness boolean. The result is deduplicated. A storage reset or unavailable history makes the boolean false. A query with no required components causes an error.
up
Query:up(component: Component | string): QueryReturns a new query requiring an ancestor carrying the specified component. The ancestor's component handle is appended to each returned row.
with
Returns a new query with additional required components or tags. Component definitions select components; strings select tags. These filters do not add returned handles.
within
Query:within(ancestor: Instance): QueryReturns a new query restricted to descendants of the supplied Instance.
without
Returns a new query excluding Instances with any listed component or tag. Component definitions select components; strings select tags.
Operators
__iter · __tostring · __type