So I'm currently thinking of the best way to structure the code for a gun
I'm thinking:
1): Client - Mouse is pressed
2): Client - While loop starts. Firing to server every 0.1 seconds
3): Client - Create the gunfire effects for this client specifically
4): Server - Processes the fired event, Handles ray-cast
5): Server - FireAllClients to handle effects
6): Client - Rest of the clients play effects, expect for the original client
A gun with a fire-rate of 0.1 seconds means (1/0.1)x60x2 = 1200 event fires between the client and the server per minute. Should I be worried? Is there a better way to do this?
Fire-rate of 0.1 seconds - now that's a minigun. Anyway, in order to reduce the amount of event fires to the server I would recommend handling raycast on the client's side and only fire an event if the raycast has a hit on a player or whatever is your target.
As for the visuals, creating the effect on the client's side for the specific player is good, because the player won't notice cleint-server latency. As for the rest of players, you don't need to fire an event to all clients in order to show gun-fire (unless you want the damage effect if the player got hit). Just make sure that the server shows the effect and it will be replicated to all clients. When the player presses mouse button down - fire event to start visuals loop on the server, but when mouse button is up - fire an event which will break the loop.