Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix the attack rate bug?

By spamming left click, you are able to bypass the attack rate. This is a local script located inside a tool. https://gyazo.com/ce9c34a3e3e6fd6e39444e5215bf6dba

local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local inputservice = game:GetService("UserInputService")

local firing = true
local equipped = false
local cooldown = false

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
	if firing == true then
		firing = false
	end
end)

mouse.Button1Up:Connect(function()
	if equipped == true then
		firing = false
		cooldown = true
		wait(script.Parent.Config.AttackCooldown.Value)
		cooldown = false
	end
end)

mouse.Button1Down:Connect(function()
	if equipped == true then
		firing = true
		repeat
			if cooldown == true then return end
			if cooldown == false then
				script.Parent.GunControlEvent:FireServer(mouse.Hit,1)
				cooldown = true
			end
			wait(script.Parent.Config.AttackCooldown.Value)
			cooldown = false
		until firing == false
	end
end)

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.