In a game with many zombies, should I find and damage the player by using raycast(from zombie torso to lookVector) or by Touched() event?
For my zombies i check to see if the player is within a certain distance then a run an attack function
local dist = zombie.HumanoidRootPart.Position - closestPlayer.Character.HumanoidRootPart.Position).magnitude -- gets the distance between the zombie and the player if dist <= 15 then if canAttack then -- if the zombie can attack canAttack = false Attack() -- your attack function wait(attackCooldown) canAttack = true end end
You just need to update this every second or when an event fires for it to work.
If you want is to count if the zombie touches the player, use :Touched()
.
If this helped you, make sure to accept the answer, it will help us both out.