I’m trying to make a bar scaling from the center. If you don’t understand, I mean sort of like this effect:
100% =
50% =
and 0% =
How would I go about calculating size? The position was the easy part.
I’m trying to make a bar scaling from the center. If you don’t understand, I mean sort of like this effect:
100% =
50% =
and 0% =
How would I go about calculating size? The position was the easy part.
When I did something similar when you tween the bar to make it smaller, also tween the bar close to the centre, it would need so maths but it works well.
For position, AnchorPoint will make life easy for you! Set the AnchorPoint to 0.5, 0.5 then set the Position to 0.5, 0, 0.5, 0. Then all you have to do is change the size of X between 0 and 1, no fancy math needed!
Here’s the calculation for health:
Humanoid.HealthChanged:Connect(function(health)
local amount = health/Humanoid.MaxHealth --This is a number between 0 and 1
Bar.Size = UDim2.new(amount,0,1,0) --Alternatively you could tween to this value!
end