Short Answer: Yes, people can loop kill by doing something like
for _, character in pairs(workspace:GetChildren()) do
pistolAttackE:FireServer(character.Head) -- As you're passing a PV Instance (basePart)
-- they could maximise damage by passing the head (dealing the most damage)
end
To the people who are saying “just raycast on the server as it’s more secure”, it wouldn’t really change much as you’d need to pass the origin position and the mouse position.i.e
PistolAttackE:FireServer(origin, mousePosition, raycastResult.Instance)
The code above would still be a security issue even if you were to calculate the raycast on the server BECAUSE the server cannot validate the origin nor mouse position, the server cannot read the source of those values (client sided); they have to trust that they’re truly from the centre of the camera and within the player’s FOV. You could try your best to validate these but you’d still be hit with issues, i.e trying to use Dot Product to check if the mouse’s hit position is actually within the player’s FOV, wouldn’t be viable as latency could really mess up shots or even if you spin really fast (legitimately).
You could add a cooldown between the fires to make sure that they’re firing the event within the RPM (which can be done by storing the weapon fired in a module). If this is a first person game then it’s a lot more harder to validate these types of things as most calculations/rendering/handling is done on the client. i.e Equipping a gun, firing the gun, etc.
Trying to protect against aimbot is almost impossible, in the old days exploiters used to use BodyGyros for aimbot which you could detect but FE wasn’t a thing.
The most you could do would be to do the following
- Thoroughly validate line of sight through the server
- Validate RPM (not sure how you’d do that as the weapon would be equipped on the client and the client could lie about their RPM)
Now you understand why FPS games have so much exploiters. Trying to make things more secure would ruin player experience, so the most you could do would be to do the best you can to secure your events and improve your game’s moderation experience. Most games should give up trying to CRACK the amazing code to prevent exploiters, but rather find a way to detect and terminate them.