How to use CollectionService.TagAdded?

TL;DR CollectionService.TagAdded fires when a new CollectionService Tag is created. If you want to trigger an event when a tag is added to an object, check the code in the solution below.

I have a list of objects and I want to trigger some code when a CollectionService tag is added to one of the objects.

I noticed in the documentation there was an event called CollectionService.TagAdded, but it has pretty much zero documentation and I wasn’t sure how it worked. Could someone explain to me what the event does and how I could solve my problem?

1 Like

I think it does what it says: Whenever a new Tag has been added, it starts a function. You can put the Name of the tag as a variable

.TagAdded is when a new tag is actually created. You should be using :GetInstanceAddedSignal to detect when new objects are added to your tag instead.

Code:

CollectionService:GetInstanceAddedSignal("MyCoolTag"):Connect(function(coolObject)

end)
6 Likes

Well the event doesn’t have an Instance parameter, so I wasn’t sure how to figure out how this would work.

1 Like

Just like @Katrist said. It only runs when a new Tag is added, not when somethings gets added in the tag.

1 Like

Alright this worked great, thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.