Get the module here:
Intro
rQuery is a free, open-source module designed to provide a more advanced alternative to Roblox’s built-in search functions (:FindFirstChild
, :WaitForChild
, etc.). It extends search functions to add more parameters to search. Currently, the module allows for:
- Searching instances for specified CollectionService tags
- Searching instances for properties with a specified value
- Defining a function to query (see
rQuery:QueryFunction
)
More features are planned! See the Roadmap below for more details.
Usage
Click me to read the API
Module
module.new(object: Instance)
Returns an rQuery object. The object
parameter is what rQuery will use for all queries.
rQuery object
rQuery:QueryFirstChildWithTag(tag: string, queryDescendants: boolean)
Returns the first child having CollectionService tag tag
. If queryDescendants
is true, rQuery will search descendants returned by object:GetDescendants()
. Otherwise, it will use instances returned by object:GetChildren()
.
rQuery:QueryChildrenWithTag(tag: string, queryDescendants: boolean)
Similar to QueryFirstChildWithTag
, but returns a table of all instances with CollectionService tag tag
, not just the first.
rQuery:QueryFirstAncestorWithTag(tag: string)
Returns the first ancestor with CollectionService tag tag
, with “first” being defined as the latest ancestor (e.g. an eligible Parent
would be returned even if game
had the tag).
rQuery:QueryAncestorsWithTag(tag: string)
Returns all ancestors of the object with CollectionService tag tag
.
rQuery:QueryFirstChildWithProperty(property: string, value: any, queryDescendants: boolean)
Returns the first descendant that has property property
of value value
. queryDescendants
has the same function as every other use here.
rQuery:QueryChildrenWithProperty(property: string, value: any, queryDescendants: boolean)
Similar to QueryFirstChildWithProperty
, but returns all eligible children, not just the first discovered.
rQuery:QueryFirstAncestorWithProperty(property: string, value: any)
Similar to QueryFirstChildWithProperty
, but queries ancestors, not children.
rQuery:QueryAncestorsWithProperty(property: string, value: any)
Similar to QueryFirstAncestorWithProperty
, but returns all eligible ancestors.
rQuery:Rebind(newBind: Instance)
Changes the Instance the rQuery object uses for all queries.
rQuery:QueryFunction(direction: string, returnAll: boolean, filter)
An all-encompassing function that can be used for all queries.
direction
has 3 valid values:
- “Children” searches the Instance’s immediate children.
- “Descendants” searches the Instance’s descendants.
- “Ancestors” searches the Instance’s ancestry.
When true, returnAll
will return all eligible objects. Otherwise, it will return only the first.
filter
is a function that will return a boolean value when called as such:
filter(instance)
Roadmap
Features currently planned for rQuery:
- An all-encompassing
Query
function that accepts a dictionary of parameters
Thanks for reading, and I look forward to the DevForum community's feedback!