CollectionService
CollectionService : Instance
Overview
A service that allows you to assign string-based tags to instances, making it easy to group and manage objects with similar properties.
Tags assigned on the server are automatically synchronized to clients, ensuring both sides maintain the same tag state.
Properties
Methods
AddTag
Adds a tag with the specified name to the target instance.
Parameters
Instance Instance
The target instance.
string TagName
The name of the tag to assign.
Return
void
Code Samples
GetTagged
Returns objects that have a specific tag assigned. Only objects that are included within the game’s DataModel hierarchy are considered. Objects whose parent has not yet been set, or objects that exist outside of the DataModel structure, are excluded from the results.
Parameters
string TagName
The name of the tag to search for.
Return
Array
An array of objects that have the specified tag applied.
Code Samples
GetTags
Returns an array of all tags applied to the target instance. Unlike HasTag(), which checks for a specific tag, it is ideal for retrieving all tags applied to an instance.
Parameters
Instance Instance
The target instance.
Return
Array
An array of strings.
Code Samples
HasTag
Returns true if a tag with a specified name is added to target instance.
Parameters
Instance Instance
The target instance.
string TagName
The name of the tag to check.
Return
boolean
Whether the tag exists.
Code Samples
RemoveTag
Removes the tag with the specified name from the target instance, and operates without errors even if the tag does not exist.
Parameters
Instance Instance
The target instance.
string TagName
The name of the tag to remove.
Return
void
Code Samples
Events
Last updated