So I'm making a gun, and I'm wondering what should be handled by the server and by the client, in the most lagless and unhackable way. Here are some information about the gun I'm making:
-Uses raycasting
-The gun holds x amount of bullets, each shot eats 1 bullet.
-The user holds x amount of spare bullets.
-Reloading
-Has a min and max spread, and each shot adds x amount of spread of the gun, and over time the spread diminishes.
-The gun draws a beam and plays sounds
-Has different firemodes (semi, auto)
-Has a gui when you equip the gun
You should ask yourselves the following questions:
--Can the server do it? --Can the client do it? --If the client does it, is there a security risk?
Examples:
Bullet count:
--Can the server do it? Yes --Can the client do it? Yes --If the client does it, is there a security risk? Infinite ammo & Never reloading. --> Server should do it.
Swap firemodes:
--Can the server do it? Yes --Can the client do it? Yes --If the client does it, is there a security risk? No. --> Client should do it.