Bar not scaling correctly?

so, allow me to explain, if you’re familiar with the clanning community, often times theres a terminal, for each second you own it, it raises your teams points (by 1 per second) and increases the bar accordingly on the top, however mine is not doing that sizing correctly, here’s my code, if you need more let me know!

function Term.UpdateBars(player, count, bar)
	local teamPoints
	if count.Name == "Team1Cnt" then
		teamPoints = TermSettings.Team1Points.Value
		count.Text = TermSettings.Team1Points.Value .. " / " .. TermSettings.Cap.Value
	elseif count.Name == "Team2Cnt" then
		teamPoints = TermSettings.Team2Points.Value
		count.Text = TermSettings.Team2Points.Value .. " / " .. TermSettings.Cap.Value
	else
		return 
	end

	local maxPoints = TermSettings.Cap.Value

	local ratio = teamPoints / maxPoints
	local targetSize = UDim2.new(ratio, 0, bar.Size.Y.Scale, 0)

	local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	local tween = TweenService:Create(bar, tweenInfo, {Size = targetSize})

	tween:Play()
end

obviously, as im sure you can see, it scales incorrectly, when it should be about halfway if not a bit more, the end of the bar (should) be going near the image label there when it reaches max capacity if that makes sense

How does the bar look like after a certain amount of points?

uh, as u can see, very stretched out at the end of the video, it was 500 and it went like all the way across my screen, it should’ve been halfway on the image i have included if its 500/900

I completely missed your video, oops!

Anyways, this is probably because the frame doesn’t have any limit. Since you’re changing the scale of the part, you gotta have some sort of maximum size for it to reach, which would be represented by 1 (900/900).


An example of this is the image above. I made a black bar called “limit”. Now, if I were to set the “Bar” frame inside of the Limit frame’s X scale to 0.5, it would be 50% of the X of the “Limit” bar, so it would fill it up halfway.

Of course, you can make the “Limit” frame transparent, that way no one can see it.

ah okay, thats probably what im missing actually, that would be exactly it, its a free-floating imagelabel so no wonder, ill add a frame for it and see how that goes

1 Like

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