UI scaling to 0, 0, 0, 0 instead of desired amount when using GuiObject.scale

I’ll keep this short.
I have a health bar, and I divide the player’s current health by their max health to find the size of the bar.
But it’s xScale = 0 nonetheless, and it doesn’t work. It’s supposed to show partial health bars.

Here’s my code:

function updateHealth(health)
	local human : Humanoid = chr:FindFirstChild("Humanoid")
	
	bar.health.Bar.Size = UDim2.new(health / human.MaxHealth, 0, 0, 0)
end

updateHealth is connected to by Humanoid.HealthChanged, and it gives it the humanoid’s health. The bar size is also calculated coorectly as I’ve given it the good ol’ print(info). But whenever my health changes, the bar appears empty!

No errors either.

Y component of the UDim2 is also 0? Scale should be 1?

1 Like

Y-axis should be greater than 0

bar.health.Bar.Size = UDim2.fromScale(health/human.MaxHealth, 1)
1 Like

@Prototrode @SOTR654 I wish I could accept both as answers; thank you.
Sometimes you just need other people to check your code. I legitimately spent 30 minutes on this.

Thank you!