Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't my healing pad healing me when there are no errors?

i'm making a healing pad but it isn't working.

Here is my script.

local db = false
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		if db == false then
			db = true
			if hit.Parent.Humanoid.Health < 100 then
				hit.Parent.Humanoid.Health = 100
				wait(2)
				db = false
			end
		end
	end
end)

1 answer

It's not working because your character have full health , this is why don't appear a error message on output.

To solve this problem, I created a block that when touched by the character, it loses life (leaves the character with 1 life always).


script.Parent.Touched:Connect(function(hit)
	
local h = hit.Parent:FindFirstChild("Humanoid")
		
if h ~= nil and h.Health > 1 then
	
h.Health = h.Health - 1
	
end
	
end)

And another block with your script :


local db = false
	script.Parent.Touched:Connect(function(hit)
	    if hit.Parent:FindFirstChild('Humanoid') then
	        if db == false then
	            db = true
	            if hit.Parent.Humanoid.Health < 100 then
	                hit.Parent.Humanoid.Health = 100
	                wait(2)
	                db = false
	            end
            end
	    end
	end)

first lose life in the first block and then go to the other, it will heal the character completely.

2 comments

0

Your script is correct, but the pad that delete 1 health is not the best way to do it. Because a normal people have a script that heal 1 health every second, so next time use :GetDamage(50) instead! c:

0

Okay :)

This discussion is preserved as it was. New answers, comments, and votes are closed.