Is there a way I can set an area, bigger than one block, to teleport players from? I'd like to randomly teleport people that are within this area to two or more destinations.

I'm making a minigame in which players all start in a hub, and a command blocks picks one of the players in the hub area randomly and teleports them to either the blue team or red team side. My problem when trying this was that it would teleport people no longer in the hub area, making it so that a person on the blue team could randomly get swapped to the red team or from red to blue.

How can I make the command only target people in a certain area?

I'm currently on Minecraft 1.10.2 for PC.

  • What do you mean by "two or more destinations"? Would they be chosen between at random? What command do you currently use for a one-block teleport area? – SirBenet Aug 27 '16 at 23:09
  • I'm trying to make a mini-game that has teams that swap players randomly after every round. The players start in a hub that at a certain time, a command blocks picks one of the players in the hub area at random and teleport them to either the blue team or red team. My problem when trying was that it would teleport someone outside the hub area, making it so that a person on the blue team could randomly get swapped to the red team or from red to blue, even when there were still players in the hub that weren't on teams yet. When I tried to fix it, it would put the teams into the hub. – DWShade Aug 28 '16 at 15:24
  • So you have the command that picks a random player and teleports them, and you want a way to make that command only target people in a certain area, correct? – SirBenet Aug 28 '16 at 16:21
  • Yes that is correct. I want to save as much space as possible with redstone, but i'm fine if I have to place multiple command blocks to have this setup. – DWShade Aug 29 '16 at 2:58

If I understood well, you want the /spreadplayers command, which teleports players to random places inside a specified area in a command:

/spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player> 

x, z: The middle of the area you want to teleport players (press F3 to see coordinates)

spreadDistacnce: The minimum distance between teleported players

maxRange: The maximum teleport distance from the x and z coordinates

respectTeams: True or false. When true, targets on the same team will be teleported to the same location.

player: The selector of what you want to teleport, eg. @p


/spreadplayers 0 0 1 10 false @a

This will teleport all players to random locations, but at least 1 block away, from x = -10 and z = -10 to x = 10 and z = 10.

Example 2 (requested in the comments):

/spreadplayers 100 100 0 5 false @r[x=0,y=60,z=0,r=10]

This command will teleport a random player that was less then 10 blocks away from XYZ 0, 60, 0 to a random location within 5 blocks of X, Z 100, 100.

For more information about the /spreadplayers command, visit the Minecraft Wiki or the Minecraft Forum

  • Can the spreadplayers command take a player at random in a small hub like area and then teleport them to a random location in side another area? – DWShade Aug 28 '16 at 15:29
  • Yes, you can. Use the command syntax at the top of the answer and use @r[x=X,y=Y,z=Z,r=R] instead of <player>. X, Y and Z are the middle cordinates of your hub and R is the max. distance from the middle coordinates. – RudolfJelin Aug 28 '16 at 15:48

There are two ways of doing this. Selectors (you're probably using @r) can have "Selector arguments". The ones you're interested in for selecting an area are:

  • x, y, z - the coordinates for the starting point of the search, useless without one of the two below:
  • r - the max radius that a player can be from the starting point (like a sphere)
  • dx, dy, dz - the max x, y, and z that a player can be from the starting point (like a cuboid)

Using a radius is the easiest method. If your hub is at 20, 64, -10 for example, you could change your commands to:

/tp @r[x=20,y=64,-10,r=15] X1 Y1 Z1

Which would TP anyone within 15 blocks of that point to X1 Y1 Z1 (set this to the red/blue team's side).

With the cuboid selectors, your starting point should be the corner of the cuboid with the lowest coordinates on all axis (so lowest north-western).

dx, dy, dz should then be the positive width, height, and length of the cuboid, as such:

Cuboid selectors

These are more complicated than a radius selector, which you might want to stick with, but will allow you a more accurate area if your hub is cuboid.


Use the radius target selector. You should use something such as @r[r=ENTER HUB RADIUS HERE]. Use this target selector in a command, eg. /tp. Hook it up to a clock that starts when pressed from a button and it should teleport everyone to different team location one by one. Use multiple command blocks of you want more destinies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.