Right now, this is how my hit detection on the client and server-side verification in my FPS game works:
1. Client shoots out a ray from the camera (of-course with spread, recoil pattern, etc.)
2. If that ray hits another player, it sends the size of the part, it’s CFrame, the CFrame of the camera, and lastly the ray’s direction to verify on the server.
3. The server replicates the part using the info the client sent.
4. The server checks if there aren’t walls between the camera’s position and the ray’s intersection point, and whether the player who sent the info is alive.
5. At last, as long as the previous if-check’s correct, the server damages the target and renders the hit to be valid!
But sometimes it doesn’t work as intended said some of my friends, which I’ve also noticed happening to myself, even though my crosshair was right on my enemy. Could be because I’m terrible at my own game, but I also get this faulty hitbox even when shooting at a still-standing testing-dummy at mid-range. Luckily it doesn’t happen for me that often because I have a relatively good internet, but for people who aren’t as fortunate as me this hitbox problem gets worse the higher the ping is.
Does anyone have suggestions on how to fix this? I will appreciate any help or suggestion!