How to make a team scale?

Does anyone know how to make a team scale? By this, I mean comparing the scores of all four teams and then displaying them at scale, where the more points a team has, the larger its scale.

I’d create a table with all the teams, and then have their points. You can store this as a variable or as a JSON table.

You can then use table.sort() to sort from lowest to highest. Grab the highest value, and use it as your pointer for the rest of the values. Your min and max range is based on that highest value
Eg: Min = 0
RedTeam = 100
BlueTeam = 200
Therefore Max = 200
From there, I would look up how to use math.clamp() on a gui for scaling.
When calculating the rest of the variables, you would just divide their score by the max (team/max) and clamp its value to a udim2 vector.

1 Like

Loop through all the teams, get their scores, put them in a table.
Then, do table.sort(), loop through the table, and change the display with the score.

local teams = iForgotHowToGetTeams:GetChildren()
local teamScores = {}

for i = 1,#teams do
	local score = teams[i].score
	table.insert(teamScores,score)
end

table.sort(teamScores,function(a,b)
	return a < b
end)

for i = 1,#teamScores do
	local score = teamScores[i]
	displayTextLabelPath.Text = score
end

I’m very sure you can make it shorter, I’m currently at school so it’s a bit hard to focus.

1 Like