0

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?

Fabian Röling
  • 20,871
  • 6
  • 39
  • 79
rappatic
  • 1,143
  • 5
  • 14
  • 35

2 Answers2

1

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.

Fabian Röling
  • 20,871
  • 6
  • 39
  • 79
0

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