I'm making a dynamite tool, but for some reason the debounce doesn't work and you can spam click to spawn more dynamite. Any fixes?
01 | local Tool = script.Parent |
02 | local Handle = Tool:WaitForChild( "Handle" ) |
03 | local Debounce = true |
04 | Tool.Activated:Connect( function () |
05 | if Debounce = = true then |
06 | PlantBomb() |
07 | Debounce = false |
08 | wait( 3 ) |
09 | Debounce = true |
10 | end |
11 | end ) |
12 |
13 | function PlantBomb() |
14 | local Bomb = Handle:Clone() |
15 | Bomb.Parent = workspace |
Here's a quickie, you should put the debounce = false
before PlantBomb()
located on line 6.
Don't worry, it'll make a lot more sense once you do it.
Put the debounce changer at the start. As it calls the function then changes the debounce. It needs to change the debounce then call the function.
1 | local Debounce = false —Debounce should always be set to false , not true . |
2 | Tool.Activated:Connect( function () |
3 | if Debounce = = false then |
4 | Debounce = true |
5 | PlantBomb() |
6 | wait( 3 ) |
7 | Debounce = false |
8 | end |
9 | end ) |