Very Critical Unknown Bug and causes lag

I have a weapon system and it somehow has a bug where if you double click really fast the firerate doubles. This might not seem as that critical but after I have been testing it out with my friends it seems to cause lag whenever somebody uses it.

I have currently 5 people in the server and when one uses the double click bug all of our ping rises about 200-400 ms. Hers the script:

mouse.Button1Down:Connect(function()
	lmbdown = true	
	if auto == true and canfire == true and equipped == true then
		while lmbdown == true and sprinting == false do
			trigger()
			wait(60/fr)
		end
	elseif auto == false and canfire == true and equipped == true and sprinting == false then
		trigger()
		wait(60/fr)
	end
end)

btw hit detection is done by raycast on the server

Try adding an extra wait() outside of any if statements.

Perhaps it’s because the script is firing the remote event so fast, causing the server to lag.

Wait, so after a bit of testing i found out that the lag is not caused by the double clicking its caused by humanoid death while still having the IKFP on. So lag is solved. I would try @IsNotJail 's method

mouse.Button1Up:Connect(function()
	lmbdown = false
end)

You should probably add this if you haven’t already. And any other scenario in which LMB should be disabled too.

Yes i’ve already done this in the original script. U can try and replicate the bug here.

Just double click and u will get a chance to double firerate, although it doesn’t cause lag everytime

If it is solved, mark this as solved so then people don’t keep coming and trying to help.

Can you give a specific example? I did it in the way how you described it but it didn’t seem to work. I want to make sure I’m doing in the way you are telling me to