I’m trying to make a health bar. I didn’t know how, so I quickly went and searched a Youtube video. I found a video, but it just gave me the script with no explanation. I’m now experiencing an issue where this happens when the player is damaged and gets their full health back:

(This is how it’s supposed to look btw)

Here is my script:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(function(Damage)
script.Parent.Size = UDim2.new(Damage / humanoid.MaxHealth, 0, 0.8, 0)
end)
I don’t know how to fix this. If you do know a solution, can you care to explain to me how it works too?

