-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation: Tags
Summary: Searches for the first child of the given ancestor instance that has a specific tag. It returns the first child that is found with the specified tag, or nil
if no such child is found.
Syntax: FindFirstChildTagged(Ancestor: Instance, Tag: (string | {string})) → Instance?
-
Ancestor
: The ancestor instance to search for children in. -
Tag
: The tag to search for. This can be a string or an array of strings.
-
Instance?
: The first child instance that was found with the specified tag, ornil
if no such child was found.
local Ancestor = game:GetService("Workspace")
local Child = Tags.FindFirstChildTagged(Ancestor, "HealPart")
print(Child)
Summary: Searches for the first child of the provided Ancestor
instance that has the specified Tag
string or any of the Tag
strings in the provided table.
Syntax: FindFirstDescendantTagged(Ancestor: Instance, Tag: (string | {string})) → Instance?
-
Ancestor
: An instance representing the object whose children will be searched. -
Tag
: A string or a table of strings representing the tags to search for.
-
Instance?
: An instance representing the first child of theAncestor
object that has the specified Tag, ornil
if no such child was found.
local Part = workspace:FindFirstChildTagged("Laser")
print(Part)
Summary: Gets the first ancestor of a given object that is tagged with the specified tag.
Syntax: FindFirstAncestorTagged(Object: Instance, Tag: string) → Instance?
-
Object
: The object whose ancestor you want to find. -
Tag
: The tag to search for on the ancestor.
-
Instance?
: The first ancestor ofObject
that is tagged withTag
, ornil
if no such ancestor is found.
local Object = game.Workspace.Part
local Ancestor = Tags.GetAncestorTagged(Object, "MyTag")
print(Ancestor) -- Outputs the first ancestor of Object that is tagged with "MyTag", or nil if no such ancestor is found.
Summary: Returns an array of children of the Ancestor
instance that are tagged with Tag
.
Syntax: GetChildrenTagged(Ancestor: Instance, Tag: (string | {string})) → {Instance}
-
Ancestor
: The parent instance to search for children. -
Tag
: The tag to search for on the children. Can be a string or an array of strings.
-
table
: An array of instances that are children of theAncestor
instance and are tagged withTag
.
local TaggedChildren = Tags.GetChildrenTagged(game.Workspace, {"TestTag", "TestTag_2"})
print("Number of tagged parts in workspace:", #TaggedChildren)
Summary: Returns an array of descendant objects from a given ancestor object that have a specified tag.
Syntax: GetDescendantsTagged(Ancestor: Instance, Tag: (string | {string})) → {any}
-
Ancestor
: The instance object to search for descendant objects within. -
Tag
: The tag or tags to search for. This can be a single string or an array of strings.
-
table
: An array of descendant objects that have the specified tag or tags.
local TaggedDescendants = Tags.GetDescendantsTagged(game.Workspace, {"Laser", "Red", "DamagePart"})
for _, Descendant in ipairs(TaggedDescendants) do
print(Descendant.Name .. " has one of the specified tags.")
end