So currently all my guns are like 90% server-sided, but that means fast-firing guns can stutter a lot from the client’s POV. I get what I am meant to do to make it look right from the client POV but I’m not sure how to do it.
This is what I am thinking:
- get user input and fire a raycast on the client
- if the ray hits, fire a remote event to the server
- fire a new ray from the server to verify it
However, how would I prevent the player from firing the event faster than I want? How would I do a check on the server to ensure the fire rate matches what the client sees to tenths of a second, and so that it doesn’t reject a raycast that is within the allowed time if they aren’t perfectly synced?
Also, I currently have it so the gun detects when the mouse button is held down, then when it is released, firing a remote to the server on each. However, if I make it so the client fires an event on every hit shot to verify it, I will be firing remotes multiple times a second, which doesn’t seem efficient?
I did find this post which gives some good detail, but I’m still unsure as to how to make everything guaranteed to line up.
Also pls bear in mind that my game is only player vs NPC rather than player vs player. Thanks in advance.