How do I make a GUI scale according to a percentage of a value?

Hey, I’ve been trying to make this statistics gui scale down according to this a “Hunger” value. I’ve searched through a lot of dev forum posts without an answer. Here is what I need:

I want the “Hunger” gui to scale to the same percentage as the value, I already have a way to make the number change but I can’t figure out how I can make the gui scale. Any ideas!

3 Likes

Do you mean you want it to be a bar that fills the gui depending on the %?

1 Like

Yes, I want the gui to size its self depending on the percentage like this:

Nope, this isn’t relative at all!

You would do this like so:
You need a frame that will be always the same size,
A “FillBar” frame inside of that frame,
The calculation would be: local percent = Fun.value / 100
You would set the FillBar frame size to Udim2.new(percent,0,1,0)

4 Likes

You would use a UDim2 to change the size of the UI element:
bar.Size = UDim2.new(1/(maxVal/leaderboard.Points.Value),0,1,0)

Now the GUI scales too big, any ideas?

1 Like

What is the hunger value?
Make sure you did Hunger.Value / 100, not the other way around

Yeah, I did Hunger.Value / 100 exactly.

1 Like

Is the FillBar frame parented to another frame?

Nope, the parent is just a screengui.

This is what you would need to do:
image

And you change the size of the FillBar frame

Well this kind of worked, I ended up doing Fun.Value / 373 and it scaled it PERFECTLY! Which is quite strange, but it worked. THANKS!

1 Like