Gun shoots faster if spamming or double clicking mouse

So if im holding or clicking mouse its shooting normally but as long as i start spamming it will shoot much faster
the code:

User.InputBegan:Connect(function(input, gameProcessedEvent)
	if ToolEquiped then
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			Mouse1Down = true
			if Settings.ToolType == "Rifle" then
				if Settings.FireMode == "Auto" then
					while Mouse1Down do
						shoot()
						GunFx()
						wait(60/Settings.FireRate)	
					end
				elseif Settings.FireMode == "Semi" then
					GunFx()
					shoot()
					wait(60/Settings.FireRate)
				end
			elseif Settings.ToolType == "Heal" then
				shoot()
			end
		end
	end
end)

Assuming that you know some scripting knowledge (let me know if you need more explanation), please note that every time you click, it fires your function “fresh.” What that means is say you clicked once, and then it starts waiting. But then, you click again, so it fires the weapons again and then starts waiting. That’s the problem.

Are you also looking for a solution or do you just want to know the problem with the code? I don’t see your goals in your post.

1 Like

Yeah, the problem was that i didnt specified that if im shooting or not, so i just added shooting variable and fixed it

3 Likes

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