Help with my clicky script

You can write your topic however you want, but ylocal debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function(x)
if debounce == false then
debounce = true
x.Parent.Humanoid.Health += 100
task.wait(10)
debounce = false
end
end)

it looks like there is an error on line 6 but I don’t know how to fix it. thanks!

also the indenting is correct it just won’t show on devforum

“x” would lead to the player. To get to the Humanoid, you would need to do “x.Character.Humanoid”.

local debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function(x)
    if debounce == false then
        debounce = true
        x.Character.Humanoid.Health += 100
        task.wait(10)
        debounce = false
    end
end)
3 Likes

Replace line 6 with x.Parent.Character.Humanoid.Health = 100

1 Like
local debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if not debounce then
		debounce = true
		local character = player.Character
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.Health += 100
		--humanoid:TakeDamage(-100) --this would do the same thing as the above line
		task.wait(10)
		debounce = false
	end
end)