This question is similar to How can I randomly power one of several wires in Minecraft?, but uses command blocks and only 3 outputs.

I'm making a Minecraft server and it has three different hubs that one can spawn in when they join the server. Each hub is identical. When a player joins a the server, they spawn in a 1x2x1 box. This box has a pressure plate on the bottom. When the pressure plate is triggered, I want to be able to randomly select one of three hubs to teleport to. Is it possible to do this through command blocks? Or will I need to make a redstone device?


2 Answers 2


Summon an armor stands at the spawn point of each of the hubs like this:

/summon armor_stand ~ ~ ~ {Invisible:1,Marker:1,NoGravity:1,Tags:["hub"]}

Then just put this command into the command block under the pressure plate:

tp @p @r[type=armor_stand,tag=hub]

This teleports the player to a random one of these invisible armor stands.

  • Wow, a brillant loophole. +1 for thinking outside of the box.
    – rappatic
    Nov 4, 2017 at 11:51
  • Actually, this is the standard way to do that. Nov 4, 2017 at 11:55
  • Oh. Still. A good solution.
    – rappatic
    Nov 4, 2017 at 12:18
  • Yep, the best. That's why people use it. :D Nov 4, 2017 at 12:25
  • Oh, wait, now that I've built it, my command block can't find the armor stands.
    – rappatic
    Nov 4, 2017 at 12:26

You need to make 3 armorstands with common tag (e.g "hub"), and place each of them to certain hub.

/scoreboard players tag @p[tag=!player,x=*,y=*,z=*,dx=0] add player
/execute @r[tag=hub,c=1] ~ ~ ~ /teleport @a[tag=player,c=1]
/scoreboard players tag @p[tag=player] remove player

* - coordinates of your box

  • This doesn't work. The first command selects no entity at all. The second command would only select players with that tag and the second half of the command doesn't work because of a bug. Nov 4, 2017 at 11:51

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