Debounce Variable Situation

I’m pretty new to scripting. Although, I came across an error when I was scripting a Debounce Variable thing. My main goal is to make the player wait a certain amount of seconds (10 seconds in this case) to heal themselves again, but when I tried to test it, it doesn’t work. Could I have any advice on how to fix this script?
image
Any help is appreciated, thank you.

What does the error message says?

The strange thing is, there’s no error in the output. It just doesn’t work in general.

I can see the issue right away, but do you mind copy pasting the code here so I can write a fix?

local debounce = true

if debounce == false then

debounce = true

wait(10)

local tool = script.Parent

tool.Activated:Connect(function()

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

humanoid.Health = humanoid.Health + 25

end)

end

local debounce = true
	local tool = script.Parent

	tool.Activated:Connect(function()

		local humanoid = tool.Parent:FindFirstChildWhichIsA("Humanoid")
	if humanoid and debounce == true then
		debounce = false
		humanoid.Health = humanoid.Health + 25
		task.wait(10)
		debounce = true
		end
	end)

should fix it

the reason it doesnt work is because debounce is true and it only does it on the call of debounce being false

Thank you so much for your help.

no problem glad i could help :slight_smile:

1 Like