I have created some scripts for a gun, and I have recently noticed that the fire rate is slow despite if I change it or not.
I have run some tests and I have noticed that whoever joins the server first, the fire rate is normal however when someone else joins their fire rate becomes delayed. I also believe that if the person who joined first is in the same region of the person who joined second both of their fire rate would be normal.
This is the piece of code with handles it on the server only:
local function CanShoot(Plr)
if math.abs(LastShot - tick()) > (60/FireRate.Value) then
if not Reloading then
if Equipped then
if Ammo.Value > 0 then
return true
else
-- Player cannot shoot
end
end
end
end
return false
end
I’m not sure what to do neither a clue on how to fix this. Any help is appreciated, Thanks.
I would say this isn’t the issue, but it is a seperate issue that could impact preformance and effiency. Consider fixing this later so there is only one gun handler for everybody. I don’t really know why there would be firerate problems. Could you send a video of what this looks like?
There is equal load on the server, if not less. With multiple scripts running at the same time, there is more threads, and more to keep track of. With one script, it’s easier to understand, as well as the server having less to work with. No matter what, this is more efficient. It will be more preformant because there are also less remote events to handle.