I want to achieve a working HP bar that goes down when the player receives damage.
I have tried watching youtube tutorials, but no matter what, my HP bar doesn’t scale correctly.
I’ve tried for 1 hour and I simply can’t get it to work.
My code:
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, 1, 0)
end)
This is the bar:
The bar’s size and position:
The bar after receiving 1 tick of damage: