How are CollectionService tags represented internally?

In almost all situations, tagged objects have their own identity, state and behavior. The pattern goes like this: when a tag is found ( CollectionService:GetTagged and CollectionService:GetInstanceAddedSignal ), create a Lua object with the Roblox instance.

Source: CollectionService documentation


No API members of the CollectionService suggest that tags are anything but associative strings on instances. That being said, if I’m understanding this correctly, the CollectionService supposedly creates objects to represent tags.

Does the CollectionService create Lua objects for tags or are they just arrays held somewhere? How are tags handled? I assume that the created object is absolutely nothing on memory and performance with dynamic management a plus (we just need to clean returned references from service methods), but this wording just confuses me.

Just to be clear: I’m asking for the sake of knowledge and out of curiosity. The response shouldn’t change one’s view on CollectionService or how they use it. As far as we’re concerned, tags are strings associated with instances and the methods return objects we can use to our advantage when working with groups of objects without hierarchical dependence.

1 Like

I think you’re misreading.

This a recommended pattern for place developers to follow, not what the engine does.

4 Likes

Oh yeah. A re-read of the article makes this apparent. Silly me. :upside_down_face: