More efficient way to damage surrounding players w/ magnitude without looping every player?

I have a script that fires a projectile that uses raycast and magnitude to check for surrounding players.
Using raycast and magnitude alone, Im only able to damage one player (because I check if the raycast hits any player I then loop through all players and see if the distance between the projectile and characters are less than 2 studs, it then damages.
I saw somewhere that getting the humanoids in a folder that has the players humanoid is available, but I forgot what it was.

1 Like

I recommend you using region3, or magnitude for it, it’ll be more complicated, but it’ll rag less

You might make a new instance and check if a player is touched, but region3 will work better

Region3 will take longer than checking magnitude and raycasting.

You’d be better off just firing 3 raycasts - the main one, then additional ones offset by 2 studs left and right. Then just get the result of each and damage those players.

You can get the player’s character from the raycast result as it returns the part that it found. FindFirstAncestorWhichIsA(‘Model’) will likely return the character.

1 Like

Im trying to figure out how to check for char in the vicinity, firing 3 raycasts would yield 3 returns. How would I go about doing that?