How to tackle this issue? Gun system related issues

Honestly, I’ve been a bit stumped on how I want to write my automatic fire rate system for my gun. I am worried about sending a server request every time the client shot since I believe that it could generate lots of lag, especially if a crowd started to fire majorly.

The solution in mind I had was to send a remote event (in which the client pressed and held M1), the server would fire a bullet for every second it was held, until running out or M1 was released, which would send another remote event.

It may seem that I am asking for a snippet of code but I am really trying to find examples of what Im tryna do so I can properly cross reference and see if my method is clean and optimized.

any help would be appreciated :slight_smile:

2 Likes

Sending a remote event every 0.1 to 0.2 seconds has barely any effect on performance. Just make sure your sending low amount of data. And the code for generating that loop should be optimized too.

4 Likes

Compress the data you send and you’ll be fine. If you don’t want to do all the hard work yourself then you can just use ByteNet which compresses the data with buffers. Afaik this is the best way rn.

2 Likes