Hi guys, i want to know how to script a health bar increases from x scale 0 to 1 more lower health is, because seems i am doing at some wrong way.
Here’s some examples images of what i mean with a health bar with anchor point set to 1,0 increasing from right to left.
X Scale 0, Health 100.
X Scale 0.25, Health 75.
X Scale 0.5, Health 50.
X Scale 0.75, Health 25
X Scale 1, Health 0
I’ve tried by making this scripts.
(Humanoid.MaxHealth / Humanoid.Health) * 1
0 * (Humanoid.Health - Humanoid.Health)*(Humanoid.MaxHealth / Humanoid.Health)
But, they doesn’t works as from what i wanted, Any ideas of how to make that?
You just need a simple fraction, how much health you have over your maximum health.
bar.Size = UDim2.fromScale(Humanoid.Health / Humanoid.MaxHealth, 1)
GFink
(GFink)
June 15, 2022, 10:53pm
#3
wait, you want the bar fully black when health is 100 and fully green at 0?
Yes, that’s what i really mean, i want that like exactly you said.(Sorry for my bad english)
RMofSBI
(RMofSBI)
June 16, 2022, 12:29am
#5
You should be tweening this to get the effect you want.
Tweening, how i do like that using tween?
Nevermind guys, i’ve found a way, i’m sorry if made y’all not understand, i wanted to make a health bar image scale without scaling the image, it was just only using the 9-Slice, but thanks for helping guys.