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

Health Bar GUI not working? [UNANSWERED]

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

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')

1 comment

0

WaitForChild called on an Instance that is not in a DataModel.

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