It shoots fast when I spam click

  1. What do you want to achieve? Keep it simple and clear!
    Making a gun and when I set the gun to Semi-fire, it shoots fine just like Semi-fire gun until I found out that the gun shoots fast when I spam click.

  2. What is the issue?
    robloxapp-20230119-1814571.wmv (1.1 MB)

  3. What solutions have you tried so far?
    I use wait() statement even not working. I’m now clueless + I’m not an intermediate scripter.

Client code below

Weapon.Activated:Connect(function()
	if not IsShooting then
		IsShooting = true
		if Automode.Value == true then -- If automode enabled then
		repeat -- repeating the fire until the "IsShooting" turn into false
			wait(AutoCoolDown)
				firing()
		until not IsShooting
	else -- if not true then it fires just like semi gun
		firing()-- FIRE
		wait(SemiCoolDown)
		end
	end
end)

If you how to solve then thanks

You may need to create another variable to create an activation cooldown, and just return the Activated event if the activation cooldown is set to true

local actCD = false
Weapon.Activated:Connect(function()
	if not IsShooting then
		IsShooting = true
		if Automode.Value == true then -- If automode enabled then
		repeat -- repeating the fire until the "IsShooting" turn into false
			wait(AutoCoolDown)
			firing()
		until not IsShooting
	else -- if not true then it fires just like semi gun
		if actCD == true then
			return
		end
		actCD = true
		firing()-- FIRE
		wait(SemiCoolDown)
		actCD = false
		end
	end
end)
1 Like

Thank you for help. Now the gun shoots fine

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.