Sanity check timing issue

Currently working on a weapon framework and running into an issue with the automatic setting I put in place.

When using this setting and holding click on the client it will run a repeat loop firing an event with an interval of the fire-rate time setting until mouse1 is released.

There is also a check on the server which determines if the client is attempting to fire faster than the set fire-rate.

The issue here is that the client waits the length of the fire-rate and then :FireServer(), but sometimes the timing will be off and the server’s delay will end a little bit after the :FireServer() is sent causing a bullet which should have been fired to simply not.

I added in a :FireClient() from the server to the client which acts as a green light to stop waiting instead of the client waiting the fire-rate time to :FireServer() again.

The issue with that is that I’m fairly sure that is a bad practice.

I do not send any data through the green light :FireClient(), however I do pass a mouse.Hit.Position through the :FireServer() which is to be expected.

If this confirmation thing I came up with is a valid practice let me know.

If it isn’t a good practice as I suspect and I need to use a different method, it would be great if you would lend me a method to try.

Thank you.

I did notice that there is a limit to how much data you can send per second over a remote, and I’m pretty sure its 50KB/s.

I don’t think I’d be going over this limit by doing this with such little data.

Can someone correct me if I’m wrong?

I believe that the remote is sending over 12 bytes of data every time I send to the server and confirm back, since the Vector3 is 3 float values, and the confirmation has no data sent with it.

I’ll be using this method unless I get a better method here.

1 Like

why not just tell the server that youre clicking, and let them do the work

1 Like

Maybe this’ll help you out

1 Like

Do fire server each time player fires the gun. Remote events are send in packets, do not worry about limits, unless you run into issues.

That being said, due to aforementioned packets, lag and general unreliability of the internet, there is no guarantee that the events will arrive regularly at the server side. You may get 5 remotes one second, and none the following 4.

For the sanity check the best practice would be to count the amount of remotes received and calculate the average, while allowing some leeway.

I would say a player that averages more than 65 shots per minute should be kicked.

1 Like

ok I’m lost here on why you aren’t just sending a request when they click and send another request when they stop clicking

no complicated checks

no spamming remote events

no way to cheat the remote event

and it’s way easier to code, easier on the client, and easier on the server