How to refer to player with lowest tag number

Hello everyone! I am making a game where each round there is a different obby map, and players have to complete it in 5 minutes, for example, then a new map appears.

I want to eliminate the player with least progress in the round, just 1 player each round.

I’ve been trying to put some “checkpoints” (its not really a checkpoint) that give the players a tag with a number, to keep their progress. If a player falls from the “checkpoint 5” they will go back to the beginning, and when steps on the “checkpoint 1” their tag number will still be 5 because i put this code in the checkpoints:

(This is for checkpoint 4)

local cs = game:GetService(“CollectionService”)

script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild(“Humanoid”) and not part.Parent >4 then
cs:AddTag(part.Parent, “4”)
end
end)

So this seems to be going well, but I need help with my main script: how to refer to the player with the lowest tag number?

The elimination would be go from Contestants team to Spectators team.

1 Like

Let’s say you somehow made a table with players as the key and their tag as a value. Using the table library’s documentation, we can see that table.sort(t) sorts a table depending on its values. From there, you can either detect the last value and move on, or you can get all keys with the same value as the last one and pick a random one to avoid conflict.

1 Like

Ok and how can i script that? I just want to know how to refer to the player with least progress