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 tag

The name of the tag to assign.

Return

void

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 tag

The name of the tag to search for.

Return

Array

An array of objects to which the specified tag has been applied.

Code Samples

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 tag

The name of the tag to check.

Return

bool

Specifies 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 tag

The name of the tag to remove.

Return

void

Code Samples

Events

Last updated