So, just like the title states, I’m not sure how to make a healthbar like the old game SAO Project Eternity. I’m mainly confused on how to do the health bar being cut off near the middle. What I mean by that is that there is a thick bar that gets thinner at the middle, but where the excess part of the bar that would be hidden is gone. I’m not sure how to do that. Anybody know?
Well so first we have to create a frame. We will call this the clipFrame
, this will cut off any part of the image which gets outside of the UI. Now we will put the actual image of the health inside of the clipFrame.
We will use SizeConstraint
for this as well we will change the X
size of clipFrame. So now set this SizeConstraint
to RelativeYY
.
Now for the clipFrame
turn on clipDescendants
. This will cut off any part of the image outside of the edges of the frame.
Now we will only change the X
size of the frame so that the health bar image does not change.
First we will have to get the exact minimum size, so when your health is 0 it is exactly equal to this.
local xMinSize = 0.01
Let’s say we need this much exactly so that it is just barely visible.
now we will get the max size, so when it is just exactly full.
local xMaxSize = 1.5
Now we get the Health
and divide it by the MaxHealth
local p = Humanoid.Health / Humanoid.MaxHealth
Now we want the size of the UI to be equal to the xMinSize
when p = 0
and xMaxSize
when p = 1
.
So this would be:
local xSize = p * (xMaxSize - xMinSize) + xMinSize
Now you jut need to calculate p
and xSize
every time the Health
changes, use :GetPropertyChangedSignal()
for this.
You just need a basic knowledge of health bars from here.