How do you size bar based on a number?

How do you size a bar based on a number? Most of the posts I looked at mostly just stop the code. I’m not really asking for full code, by the way. Correct me if i’m wrong.

1 Like

You want to have a frame (the bar holder) and another frame inside of it (the bar). This makes it a lot easier.

Then, just set the size with a UDim2 value. You could use the TweenService to make it look smoother.

local bar = path_here

local number = 3
bar.Size = UDim2.new(number / 10, 0, 1, 0)
1 Like

For some odd reason, it’s not resizing at all.

Is that a part in the workspace? you’d need to use a Vector3 value for that. Can you send the script you’re using as well?

while task.wait() do
	local bar = Meter.Frame.Bar

	local number = Percent
	bar.Size = UDim2.new(number / 10, 0, 1, 0)
end

Can you mention what exactly you want to achieve? Are you trying to make a progress bar?

I’m trying to make it scale the Y Scale depending on the Percent value.

This should be working

local value = --The amount
local total = --The total amount

local bar = --The bar that is inside the other bar

bar.Size = UDim2.new(1,0,value/total,0)

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.