Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I fix the attack rate bug?

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

Denounces. You can use denounces to make it so the user cannot swing again until a certain amount of time.

https://developer.roblox.com/articles/Debounce

0
This is an automatic weapon, and by the time this was posted I got it fixed so... Eh... Reset935681 5 — 4y
0
Ah, sorry thought it was a sword Neon_isHere 100 — 4y
Ad

Answer this question