basically, the tool swings without delay if you click fast enough, but in the code i added a debounce that only works if you dont spam click, so how should i add a cooldown that actually work:
CODE(server script) :
Bat.Activated:Connect(function()
if not Debounce then
if Swings == 0 then
SwingRight:Play()
Swings = 1
task.wait(.35)
newHitbox:HitStart()
Swing1Sound:Play()
elseif Swings == 1 then
SwingLeft:Play()
Swings = 2
task.wait(.35)
newHitbox:HitStart()
Swing1Sound:Play()
elseif Swings == 2 then
SwingOverHead:Play()
Swings = 0
task.wait(.25)
newHitbox:HitStart()
Swing2Sound:Play()
end
end
Debounce = true
task.wait(Cooldown)
Debounce = false
end)
Where is the variable Cooldown (3rd last line) set? You may have an issue with that code instead of this one.
wait(.25) or wait(.35) isn’t very long at all, so is the spamming only waiting that long?
Try printing Cooldown to see what it’s doing.
it set at the top, like this: local Cooldown = 3, the cool down works (like i stated before) but if you spam activate (or click) the tool, the debounce just wont work in general. (it prints 3)
if not debounce should work, though you need to filter the debounce as soon as possible. You filtered your debounce 0.35 seconds after it is called, meaning that requests can be made within that amount of time.