I want to make a minigame world where you press a button and it has 3 command blocks behind it that teleport you to different areas. But I don't know how to make it select one random command block

  • Some googling got me this: imgur.com/a/xrz66 It's 2am here and I'm too tired to turn it into an answer so I'll just leave it here. Aug 4, 2014 at 1:24
  • It is a duplicate due to the fact the same solution can be used.
    – Flaunting
    Aug 4, 2014 at 8:29
  • @Flaunting A duplicate is based on the question, not the answer. Two completely different questions might have an identical answer, doesn't make them duplicates. (This one is a duplicate though, the question is essentially the same)
    – Arperum
    Aug 4, 2014 at 8:51
  • 2
    Voting to reopen because since that question was asked command blocks have been added and are mentioned in the question (as opposed to the vanilla redstone in the original). Aug 5, 2014 at 3:15

1 Answer 1


I have a possible answer, there is just one problem... it has four outputs and not three.

I have it build with dropper, hopper and a comperator. The first comperator random selects the secound path and the secound comperator selects the output. I build that thing on my offline map:

Overview Rightclick on the picture and press show picture to enlarge the image.

I have put commandblocks to the output fields. The black wool is the input. To get the best result you should put the commandblocks at the red wool. Furthermore it is important that you use the command with selector commands (I use range)!

On my world I tested it with the command gamemode /gamemode 1 @p[r=3,rm=1].

r is the max radius, rm is the min radius

If you don't do that, there is the possibility that up to 3 other player who not pressed the button are selected for the teleport. The r=3 is calibrated to the red wool and the red sand.

You also have to add a delay with Repeaters to the commandblocks so the block farthest away is always executed as first (the before last as third and so on). Keep in mind that I forgot that in the picture above!

To get the high complex random working you have to put in every hopper a tool and a block or a item.

Hopper Rightclick on the picture and press show picture to enlarge the image.

Keep in mind that I use the original Minecraft without a server neither plugins. If you use warps or other commands you have to try out if the selector argument is working.

The solution with the range is not perfect because the radius could select a other player too if he is in the radius. If you do not want that you should use the argument @a[x=100,y=60,z=-80,dx=4,dy=2,dz=5]. With that all people in the cube are selected. So you should enter the coordinates above the red sand so only the one player wich is standing on the red sand is selected for the teleport.

  • This setup won't work properly, since the "tool" will trigger the redstone for the "block" choice as well. You need to rig it so that one option excludes the other one.
    – MrLemon
    Aug 4, 2014 at 12:36
  • @MrLemon I dont know what you mean now? You mean that there could be all four commandblocks executed? I know that that is the reason why I described it in my answer. So you have to use the range argument so only the player on the red sand is teleportet!
    – Gerret
    Aug 4, 2014 at 19:19
  • Ahh, that's what you mean with the random other players. In that case, I think you need to add delays to the repeaters, so that not all command blocks are powered at the same time, which might produce undefined behavior. Two ticks on the first repeater after each hopper should work. That way, the Command Block "farthest away" from the button that gets powered is executed first in all cases.
    – MrLemon
    Aug 5, 2014 at 7:37
  • @MrLemon OOH thats true I forget about that, yes you are right the block farthest away is executed always as last in my answer. I will fix that...
    – Gerret
    Aug 5, 2014 at 7:44

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