Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
rpg523 13
4 years ago

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.

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: Xapelize 2658 — 4y
0
Okay :) rpg523 13 — 4y
Ad

Answer this question