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?
local Tool = script.Parent local Handle = Tool:WaitForChild("Handle") local Debounce = true Tool.Activated:Connect(function() if Debounce == true then PlantBomb() Debounce = false wait(3) Debounce = true end end) function PlantBomb() local Bomb = Handle:Clone() Bomb.Parent = workspace Bomb.CanCollide = true Bomb.Anchored = false Bomb.Transparency = 0 wait(3) local Boom = Instance.new("Explosion") Boom.Parent = workspace Boom.Position = Bomb.Position Boom.BlastRadius = 16 Bomb:Destroy() end
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.
local Debounce = false —Debounce should always be set to false, not true. Tool.Activated:Connect(function() if Debounce == false then Debounce = true PlantBomb() wait(3) Debounce = false end end)