OK I’m back. First, I wholeheartedly agree one one point: don’t get your naming conventions twisted, tags or otherwise. Second, I make recommendations based on what works for me. I’ve been at Lua for a few months, so I’m by no means an expert. That said, CollectionService will not cause performance issues before my skinned mesh parts cause performance issues. I will break studio with animations.
The only issue I have run into with tags, and can gladly come back to for the OP, is that communication from CollectionService only really works from the server to the client. If you update a tag on the client, the server ignores it. That was a minor hurdle, otherwise tags are amazing.
I would not build a table that persists through game states. I find CollectionService is more versatile and it builds the tables for me.
I am sensing clues from the OP that leads me to recommend Tags over a table. I do not believe the greater purpose of this table is to fire-and-forget. Parts will be accumulated, either all at once (explosion), or over time (zombie apocalypse), and then something else important happens.
In an explosion, a table would handle the allocation of damage once to each player. Easy enough. But what if that explosion had a sustained effect, like acid or fire? I would then want to monitor the states of those objects. I would not include my acid damage code inside my explosion code, though I suppose I could. I would tag the players affected, dish out damage via sustained effect code, and remove the tag via death or item use.
Summary #1: I could use a table… but I’d program with tags, just in case I get ambitious.
In a zombie apocalypse, I would have countless interactions between infected and uninfected players and NPCs. That’s perfect for CollectionService. I don’t need to look up a table at all. Just grab “HasTag” each time 2 characters meet. I can’t imagine how a table would be more efficient when the number of infected grows. I have the characters, so I look at them.
Summary #2: Tags are labels, just read the label.
Personally, I use tags as a monitoring service, similar to the zombie apocalypse scenario. My npcs have multiple states that they will go through:
- Aggro
- Chasing
- Ranged combat
- Melee combat
- Lost aggro
- Return to spawn, or despawn
- Idle
It would make no sense to monitor hundreds/thousands of idle NPCs in relation to dozens/hundreds of players. So I tag which areas the players are in (by collecting parents of touching parts), and only check for aggro in those areas. I tag when aggro conditions are met, then only move those NPCs, check for combat, add/remove tags, and so on.
Summary #3: Tags can be used for efficiency too.
/shrug