How can I make a better server-side verification?

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!

1 Like

I think this could be a network lag issue.

If you go into Studio settings (Alt+S), go into the Network tab, and set “Incoming Replication Lag” to something like 500 (simulating 500ms of ping), do you get the same issue? If it is the issue, you might need to implement a lag compensation system. I can help you with this if you want, but there’s many topics on here explaining how to do it and how it works.

Remember to change the setting back of course, once you’re done. You probably don’t want to be playing with 500ms ping in studio.

1 Like

Alright, I’ll try that as soon as possible and leave my results here. Thanks!
I also failed to mention another important aspect on how the client hitbox and server-sided verification works. Should be updated now

The hitboxes stayed the same. Thanks for the help though!