I am trying to make a health display script which seems to only work in studio but not in the actual game.
I get no errors at all in studio but in game it says "Players.Aepi.PlayerGui.StatsUI.HealthDisplay.Health.Health.Health:1: attempt to index field 'Character' (a nil value)"
To be honest i'm not sure what this error means, if someone could help that would be nice and thank you!
local Human = game.Players.LocalPlayer.Character.Humanoid
function update()
local hpMath = Human.Health / Human.MaxHealth
script.Parent.Size = UDim2.new(hpMath,0,1,0)
script.Parent.Size = UDim2.new(hpMath,0,1,0)
if Human.Health < Human.MaxHealth / 4 then
script.Parent.BackgroundColor3 = Color3.new(255, 0, 0)
elseif
Human.Health > Human.MaxHealth / 4 then
script.Parent.BackgroundColor3 = Color3.new(47/255, 255/255, 123/255)
end
end
update()
Human.Changed:connect(update)

2 comments
This is a local script also!
It means the script is loading before the Character spawns.