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

Health Bar GUI not working? [UNANSWERED]

Asked by
Relatch 550 Moderation Voter
9 years ago
local char = script.Parent.Parent.Parent.Character
hum = char.Humaniod
hum.Changed:connect(function()
    script.Parent.Frame.Health.Frame.Size = UDim2.new(hum.Health/hum.MaxHealth,0,1,0)
    script.Parent.Text.TextLabel.Text = ""..hum.Health.."/"..hum.MaxHealth..""
    if hum.Health <= hum.MaxHealth*0.30 then
        script.Parent.Frame.Health.Frame.BackgroundColor3.new = Color3.new(255,0,0)
    else
        script.Parent.Frame.Health.Frame.BackgroundColor3.new = Color3.new(0,255,0)
    end
end)

I get this error:

Humaniod is not a valid member of Model

1 answer

Log in to vote
0
Answered by 9 years ago

The only problem I can see is that on Line 2 you forgot to wait for the humanoid to exist!

Simple fix...

Change Line 2 to this:

hum = char:WaitForChild('Humaniod')
0
WaitForChild called on an Instance that is not in a DataModel. Relatch 550 — 9y
Ad

Answer this question