for _, v in pairs(game.Players:GetPlayers()) do
	local blue = {}
	local red = {}
	if v.TeamColor == BrickColor.new("Cyan") then
		table.insert(blue, v)
	else
		table.insert(red, v)
	end

	local gameFolder = v:WaitForChild("GameFolder")
	if gameFolder then
		local kills = gameFolder:WaitForChild("Kills")
		local deaths = gameFolder:WaitForChild("Deaths")
		local points = gameFolder:WaitForChild("Points")
		if kills and deaths and points then
			for _, bluePlayers in pairs(blue) do
				-- Sort from top to bottom [blue]
			end
				
			for _, redPlayers in pairs(red) do
				-- Sort from top to bottom [red]
			end
		end
	end
end

What I have my script do is create 2 tables, red and blue What I am then doing is sorting the players into their respective tables, based on their TeamColor

Now I am trying to go through the players in each table, and then sort them in order from whoever has the highest to the lowest amount of points. I am stuck, as I don't know what to use to order the players.

The reason I am trying to achieve this is I have a Frame that pops up at the end of a game, which is going to show the 2 teams, with the list of players on each team, and have whoever has the highest amount of points at the top, second amount, etc. for each team.

2 comments

2

table.sort

1

Yes, table.sort would be your best bet because it sorts things from highest to lowest. If you're sorting strings please note that uppercase is worth less than a lowercase.