Handling ammo usage for guns

So I’m wondering how one would handle ammo usage for guns.
I don’t want to put the client in charge of handling ammo as this would obviously lead to a window for exploitation (at least I think that’s the case)

Would using a table in a ModuleScript to store current gun information in a table be efficient?
Something like:
User = {CurrentClip = 15, MaxClip = 30, CurrentReserve = 100, MaxReserve = 300}

Is this an efficient way of doing it, or is there a better way to handle this? This is especially concerning me with RemoteEvents and RemoteFunctions, seeing as updating the ammo counter every time a gun fires would be firing the even a lot and possibly throttle.

Any advice would be appreciated. Thanks

I personally still opt to keep ammo on the client for the purposes of negating input lag (I value UX over exploiter accommodation), but you could probably keep ammo on the server. One thing you could do is keep ammo on both the server and the client. The client can use its ammo counter for visual representation purposes while the server validates and uses this information when propagating certain things to other clients or the server (effects, damage, whatever).


Honestly I think its fine if you handle the ammo counts on the client. That way you won’t have any delays between shooting and displaying the ammo count. You can also keep track of the player’s ammo on the server every time they shoot and reload to prevent hackers from shooting more bullets than they have.

1 Like

Makes sense. Would I send the current client’s ammo count to the server for validation checks or is this bad practice?

No. The client does not pass its ammo counter to the server for any reason. The server passes ammo information to the client so the client knows what to base its own values off of. When the client passes input, the server enacts its validation procedure and then modifies values accordingly.

The client uses ammo information received from the server to help with its own functions. Those include determining what animations or sounds to play based on the values, or for updating UIs. The server’s ammo count determines the actual ammo value for its own functionality (e.g. if server ammo count is 0, don’t pass any damage functionality).


Thank you.

You should always handle stuff like ammo count on the server and all other settings stuff as posible. Exploits can modify the ammo upvalue in your functions and change their ammo/make infinite ammo

1 Like