How good is collection service for optimisation?

In my game, players can damage other players by throwing different moves, moves such as a part that is propelled forwards and has a .Touched event to find out if it hits a player.

I do this by doing touchedPart.Parent:FindFirstChild(“Humanoid”) or touchedPart.Parent.Parent:FindFirstChild(“Humanoid”) if it’s hit an accessory. However, I always thought that find first child is quite slow, and having this happen many times in a short place could be harmful for script performance. So I was thinking, would it be wise to put all the characters parts into a collection service and check if a touched part has a “Player” tag for example. Note that I would have to change a significant portion of scripts for this and I was wandering if it’s worth it.

I plan on expanding my game and I’m getting very few reports of performance issues on slower devices when attacking.

I think there are three ways you can further optimize this:

  1. You can use the CollectionService to tag all player parts as that player’s name (so that there are different tags for different players).

  2. You can insert a .Touched script inside of the player parts instead of the projectile itself. That way, the number of those scripts would not increase like projectiles would when they’re fired repeatedly.

  3. You can simply use the dot operator (like workspace.Part) and have that wrapped in a pcall() to catch any errors if the object does not exist. Though, I believe that :WaitForChild() instead of :FindFirstChild() would be a better solution. The DevHub strongly advises using either the dot operator or :WaitForChild() over FindFirstChild():

Of course, you can combine the bullets you think is viable for your game or you can use just one of them, but either way, I hope that helps!