> For the complete documentation index, see [llms.txt](https://docs.overdare.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overdare.com/development/api-reference/classes/collectionservice.md).

# 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` |   |
| ------ | - |

#### 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` tag | The name of the tag to search for. |
| ------------ | ---------------------------------- |

#### Return

| `Array` | An array of objects that have the specified tag applied. |
| ------- | -------------------------------------------------------- |

#### Code Samples

```lua
local Part = script.Parent
local CollectionService = game:GetService("CollectionService")

CollectionService:AddTag(Part, "SomeTag")
```

### 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

```lua
local Part = script.Parent
local CollectionService = game:GetService("CollectionService")

local Tags = CollectionService:GetTags(Part)
print(Tags)
```

### 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` | Whether the tag exists. |
| ------ | ----------------------- |

#### Code Samples

```lua
local Part = script.Parent
local CollectionService = game:GetService("CollectionService")

local hasTag = CollectionService:HasTag(Part, "SomeTag")
print(hasTag)
```

### 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

```lua
local Part = script.Parent
local CollectionService = game:GetService("CollectionService")

CollectionService:RemoveTag(Part, "SomeTag")
```

## Events
