Basically this script should continuously update the GUI of the Humanoids Health but instead it errors, I really can't figure out why...
Code:
wait(0.1)
while true do
local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local hp = Humanoid.Health/100
script.Parent:TweenSize(UDim2.new(hp,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.15)
wait(.2)
end
Error Given:
Players.PastDays.Backpack.HoneyBadger.clientMain.mainGUI.HP.Frame.HealthDisplay:3: attempt to index field 'Character' (a nil value)
Any help appreciated!

4 comments
because the character might not have been loaded when line 3 was ran
you cant just have a wait(.01). that means wait for 1/100 of a second. you need to wait at least 1 second before running the script.
the best way to tell when it loads is by adding
player.CharacterAdded:Wait()local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()