The output error redirects to line 2. Here is the following code:
player = game.Players.LocalPlayer playerHumanoid = player.Character.Humanoid function update() local hp = playerHumanoid.Health local maxhp = playerHumanoid.MaxHealth local health = hp / maxhp if health <= 0 then script.Parent.Bar:TweenSize(UDim2.new(0.01, 0, 1, 0), "Out", "Quad", 0.2) script.Parent.TextLabel.Text = "0/"..maxhp.." Health" end script.Parent.Bar:TweenSize(UDim2.new(health, 0, 1, 0), "Out", "Quad", 0.2) script.Parent.TextLabel.Text = math.floor(hp+0.5).."/"..maxhp.." Health" end update() playerHumanoid.HealthChanged:connect(update)
I have a feeling that it has to do with the lack of code that checks if the model has or doesn't have the humanoid object, but usually it only has to do with buttons that are touched (if I am correct).
You're probably making it run too early. Try waiting a second or so for the Humanoid to load.
Try FindFirstChild("Humanoid") or WaitForChild("Humanoid")