So for a UI like this, you’ll want to design your hierarchy like this:
ScreenGui
VitalsWrap (Frame)
UIAspectRatioConstraint
BorderElement (ImageLabel)
HPFillWrap (Frame)
HPBar (Frame)
MPFillWrap (Frame)
MPFillBar (Frame)
The goal of setting up the UI like this is to enforce a parent-child relationship whereby everything is scaled with the parent element.
To start with, set up the Wrap element by setting its AnchorPoint to 0.5, 1
– this sets the anchor of the GUI to the bottom center, meaning that wherever it is positioned, it will scale upwards and around the center. Now, set the Position of the bar using Scale, try {0.5,0},{0.9,0}
. This assumes you want these bars at the bottom center of the screen. Finally, set the size of the bar using Scale - for starters, just set the size to {0.5,0},{0.5,0}. Don’t worry if it looks too large, that’s why we have the UIAspectRatioConstraint.
With the Wrap set up, the next step is to define the UIAspectRatioConstraint. It seems a little confusing at first, but all you need to do is divide the width of something by the height of something. For example, an image that is 1600x900 will come out to be 1.7778
, while an image that is 900x1600 will be 0.5625
. Divide the width of your health bar image by the height of the health bar image, then set that as the AspectRatio. This will force your wrap to always be the correct shape for your image.
Next step is to add your image. Just insert the ImageLabel, set its border and background to transparent, then set its size to 1,0,1,0
. The image will now take up the entire size of the parent Wrap element and be perfectly shaped all of the time.
Finally, you can add your health/MP bars. Set the size and position of the wrap elements using Scale. You can then add a frame as a child of the wraps that has its size set to {1,0},{1,0}
and simply change the X scale value for how much you wanted it filled.
If you need any more help, just leave a reply and I’ll be happy to give you answers. If need be, I can create a mockup for you to look at.