Mouse.Button1Down:Connect(function(Mouse) local Firing = true if Active and Firing then Firing = false Dead() TankRnd() end wait(5) Firing = true end)
This is my code to fire my Tank cannon basically but I cannot seem to get the debounce to work properly and then you can spam fire it which is no bueno...
Any help would be greatly appreciated.
The answer is the debounce has got to check if the firing is not false, which will then set it to true. You could make this look simpler by not putting it on the same line, but checking that both of them are correct to continue with your script.
Not entirely sure if this will work, but it's worth a shot.
Code:
local firing = false Mouse.Button1Down:Connect(function(Mouse) if active then if not firing then Firing = true Dead() TankRnd() wait(5) firing = false end end end)
Please accept my answer if this works for you.
Mouse.Button1Down:Connect(function(Mouse) if Active then if not Firing then if Firing then return end Firing = true Dead() CreateBullet() wait(1.5) Firing = false end end end)
This is it. Figured it out.....thank you all so much for all the help. Really appreciate it
The problem is (I think) is you need to put wait(5)
and Firing =true
in the if statement in order it to work and you have to set local firing = true
outside the function block
so the script should be
local Firing = true Mouse.Button1Down:Connect(function(Mouse) if active then if Firing then Dead() TankRnd() wait(5) Firing = true end end end)