FireRate problems

Hello there.

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
					-- Player cannot shoot

	return false

I’m not sure what to do neither a clue on how to fix this. Any help is appreciated, Thanks.


This seems like the issue. What is FireRate.Value set to?

The Fire Rate has been set to 1000.

However, the Fire rate is fine for the person who joins, its the person who joins after which its an issue for.

Is the LastShot variable different for each player? If not, only one player can shoot at a time.

No, there is a script in each player’s gun which controls their gun not others.

I’m confused about what the Plr argument is then? I can think of a reason or two, but I’m not sure.

Oh, the Plr argument is just the player that is passed on during OnServerEvent.

So you’re saying that every gun has their own server script that handles their own remote event?

Yes every single gun has their own server script.

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?

What would be the benefits of a one-gun handler? All I see is more load on the server and no benefits.

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.