Hey! I currently am having issues with a weapon system I am creating, there is a ton of server lag. Let me explain how this system works;
There is a module with gun information, for each weapon. The serverscript requires the module, and goes from there. When the player uses the weapon, or shoots with it, it invokes the server, with a table of 5 different information;
- The gun Name
- The Ammo type
- The gun barrel
- The gun’s current state ( Reloading, Shooting, ect. )
The server takes this Data, and checks what ammo the gun uses. It then checks the module for that gun, and then does a function to fire the bullet(s). In a module, you can have the gun shoot as many bullets as you want. If its a shotgun, each bullet will get a random area, and then it sub ducts the guns barrel position and mouse position. Once done, it raycasts, and duplicates a beam into a part that is then created. Once this is all done, the bullets will display, if any of the bullets hit a humanoid, it will damage it. The issue is, when in a server, it lags a LOT, and there is a bit of a delay, I lessened the delay by removing a few wait() statements, but now there is still a delay, is this way of guns efficient, or is it not and I should use a different method? How would I reduce the delay?
Any help would be appreciated, thanks!