Health tool not working (debounce)

Hello developers, Today I’ve made a tool that gives you +10 health for every time you click it but I also made a debounce for it so you can’t just spam click for infinite health. But it doesen’t quite work how I want it to. For example if I am 10/100 health and I keep spam clicking then after a second I get a bunch of health .
Here’s the script:

Debounce = false

if Debounce == false then

Debounce = true

end

local tool = script.Parent

tool.Activated:Connect(function()

local humanoid = tool.Parent:FindFirstChild(“Humanoid”)

wait(1)

Debounce = false

humanoid.Health = humanoid.Health + 10

end)

Can anyone help?
Thanks!

Try this code:

Debounce = false

if Debounce == false then

Debounce = true
local tool = script.Parent

tool.Activated:Connect(function()

local humanoid = tool.Parent:FindFirstChild(“Humanoid”)

wait(1)

Debounce = false

humanoid.Health += 10
  end
end)
1 Like

the debounce is actually not inside the event

local Tool = script.Parent

local Debounce = false

Tool.Activated:Connect(function()
	if not Debounce then
		Debounce = true
		Tool.Parent.Humanoid.Health += 10
		wait(1)
		Debounce = false
	end
end)
2 Likes
local Tool = script.Parent

local Debounce = false

Tool.Activated:Connect(function()
	if not Debounce then
		Debounce = true
		Tool.Parent:WaitForChild("Humanoid").Health += 10
		wait(1)
		Debounce = false
	end
end)

You should use ‘:WaitForChild’.

Tool.Parent:WaitForChild("Humanoid").Health += 10
1 Like
local Debounce = false

local tool = script.Parent

tool.Activated:Connect(function()
if not Debounce then
    Debounce = true
    local humanoid = tool.Parent:FindFirstChild(“Humanoid”)
    humanoid.Health = humanoid.Health + 10
    task.wait(1)

    Debounce = false
    end
end)
1 Like