i have this hammer tool and there is this cooldown and when the cooldown ends the hammer can be used, but somehow after the cooldown i can click infinitely and the tool will activate, can somebody help me on this matter?
tool.Activated:Connect(function()
if not db then db = true
local character = tool.Parent
local humanoid = character:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
hitbox.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
humanoid:TakeDamage(15)
handle.Hit:Play()
end)
animationTrack.Stopped:Wait()
end
wait(cooldown)
db = false
end)
local LastUpdate = 0
tool.Activated:Connect(function()
if os.time() - LastUpdate >= cooldown then
LastUpdate = os.time()
local character = tool.Parent
local humanoid = character:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
hitbox.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
humanoid:TakeDamage(15)
handle.Hit:Play()
end)
animationTrack.Stopped:Wait()
end
end)
tool.Activated:Connect(function()
if db == false then
db = true
local character = tool.Parent
local humanoid = character:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
hitbox.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
humanoid:TakeDamage(15)
handle.Hit:Play()
end)
animationTrack.Stopped:Wait()
wait(cooldown)
db = false
end
end)
tool.Activated:Connect(function()
if not db then db = true
local character = tool.Parent
local humanoid = character:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
hitbox.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
humanoid:TakeDamage(15)
handle.Hit:Play()
end)
animationTrack.Stopped:Wait()
end
wait(cooldown)
db = true
end)