I’m making a game where you shoot the enemies, these usually come in hordes on tens.
However, they seem to cause a bunch of server lag, which made me scratch my head for a couple days.
The way the system works is:
-In a single script, use a while loop (0.2 seconds) and use for i, v loop with CollectionService:GetTagged to get all the tagged humanoids.
-Check if the tag is the “Enemy” tag.
if the checks are met, do the following:
-Find a player X studs away from the enemy
-If the player is found, fire a bullet
If anyone has a suggestion on how to improve the code, please let me know