01 | Mouse.Button 1 Down:Connect( function (Mouse) |
02 | local Firing = true |
03 | if Active and Firing then |
04 | Firing = false |
05 | Dead() |
06 | TankRnd() |
07 | end |
08 | wait( 5 ) |
09 | Firing = true |
10 | 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:
01 | local firing = false |
02 |
03 | Mouse.Button 1 Down:Connect( function (Mouse) |
04 | if active then |
05 | if not firing then |
06 | Firing = true |
07 | Dead() |
08 | TankRnd() |
09 | wait( 5 ) |
10 | firing = false |
11 | end |
12 | end |
13 | end ) |
Please accept my answer if this works for you.
01 | Mouse.Button 1 Down:Connect( function (Mouse) |
02 | if Active then |
03 | if not Firing then |
04 | if Firing then |
05 | return |
06 | end |
07 | Firing = true |
08 | Dead() |
09 | CreateBullet() |
10 | wait( 1.5 ) |
11 | Firing = false |
12 | end |
13 | end |
14 | 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
01 | local Firing = true |
02 |
03 | Mouse.Button 1 Down:Connect( function (Mouse) |
04 | if active then |
05 | if Firing then |
06 | Dead() |
07 | TankRnd() |
08 | wait( 5 ) |
09 | Firing = true |
10 | end |
11 | end |
12 | end ) |