I'm trying to make an event for a server. The goal is simple, you have to do as many tasks as possible before the timer runs out. I already figured the timer out.

However, here's the catch. I want to teleport somewhere else the 3 players that have the highest score, the second highest and the third highest. I have a different room for each of them.

I tried at first to teleport the player somewhere if they had completed 20 tasks, somewhere else for 15 and 10. But there may be 3 players that have done 10, 11 and 12 tasks, in that case they would all go into the third room, but I need them to get teleported to different places.

  • Minecraft 1.12.2 or 1.13.2? Mar 4, 2019 at 14:54
  • Minecraft 1.13.2
    – Gothilawn
    Mar 4, 2019 at 14:58
  • How are you detecting which players get 1st, 2nd or 3rd? Are you using scores? Mar 4, 2019 at 16:59
  • @SpiceWeasel I think that's his question. Mar 4, 2019 at 17:24
  • @Gothilawn Is your question how to find the player with the highest, second highest, etc. score? If yes, I would edit it a lot to make that more clear. Mar 4, 2019 at 17:58

1 Answer 1


If you want to keep the numbers, first copy the scores to a temporary scoreboard, because some will get removed during the calculation. This command copies everyone's score in the scoreboard tasks to the scoreboard temp:

/execute as @a run scoreboard players operation @s temp = @s tasks

Then you give a dummy player the lowest possible value in that scoreboard. A name starting with $ cannot occur as a real player name.

/scoreboard players set $highest temp -2147483648

Here comes the magic: scoreboard players operation […] > assigns the higher of two values to the left side, in this case $highest's score in temp. By comparing every player's score with $highest this way, you end up with the highest value, because it increases the score of $highest every time it encounters a higher value in any of the players' scores.

/execute as @a run scoreboard players operation $highest temp > @s temp

Now you can do something with a player that has the same score as $highest in that scoreboard:

/execute as @a if score @s temp = $highest temp run tp @s <coordinates>

To get the second player, the third and so on, you just need to repeat that process without the player(s) with the highest value:

/execute as @a if score @s temp = $highest temp run scoreboard players reset @s temp

Now use commands 2, 3 and 4 again, with a new teleport target.

  • Might be a good idea to put all of this into a couple of function files.
    – MBraedley
    Mar 5, 2019 at 15:01
  • Sure, if you want to do that. It's just those commands without slashes, I would expect everyone who uses functions to be able to do that themselves. Mar 5, 2019 at 19:13
  • I was talking more about the glue commands to make this work seamlessly. Make it a drop-in solution, as it were.
    – MBraedley
    Mar 5, 2019 at 19:21
  • Since you need to do something with the first, second, etc. player, this would need a modification by the player anyway. Mar 5, 2019 at 21:31
  • Thank you Fabian Röling, it works great, my event works now thank you one million times ^^
    – Gothilawn
    Mar 6, 2019 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .