Mini gun shoots twice as fast when clicking fast enough

I’m making some over the should gun game and my test minigun and when you are clicking fast enough, you can have the minigun shoot twice as fast.

This is shown in this video:

Also, in this function, I am using Context Action Service instead of User Input Service:

elseif actionName == "Fire" and inputState == Enum.UserInputState.Begin and Shooting ~= true and YieldGun == false then
		-- I believe it's in this block of code
		Shooting = true
		if Automatic == true then
			while Shooting == true and YieldGun == false do
				if Ammo > 0 then
					AudioE:FireServer("Fire", "NoAmmo")--Function for playing sound on the server
					Ammo -= 1
					Fire()
				else
					AudioE:FireServer("NoAmmo", "Play")--Function for playing sound on the 
				end
				task.wait(FireRate/60)
			end
--[[
		else
			if Ammo > 0 then
				YieldGun = true
				AudioE:FireServer("Fire", "Play")
				Ammo -= 1
				for i = 1, BulletAmount do
					Fire()
				end
				task.wait(FireRate/60)

				YieldGun = false
			else
				AudioE:FireServer("NoAmmo", "Play")
			end
		end
]]
	end

I tried the devforums for the solution for my problem and they are no help. Any help is appriciated! :slight_smile:

1 Like

Whenever you click it shoots a bullet right?

2 Likes

Yes, when you hold down the mouse, it shoots bullets continually until you ran out of ammo or when you release the mouse.

I believe this is because there is no cooldown for clicking to shoot, you only implemented the cooldown for holding to shoot. Try to add the same task.wait(FireRate/60) and a debounce variable to allow shooting and cooldown for the single click fire?

1 Like

I think when you spam click, you’re calling the function every time you click. When this happens, task.wait(FireRate/60) wouldn’t be accounted for.

This might be an unusual thing to ask but if you have an autoclicker, could you try use it with your weapon?

1 Like

I don’t have an auto clicker, but I see it makes sence because there’s no cooldown of shooting the weapon. I’m going to try mrswagmoney64290’s advice.

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