TransWikia.com

How can I teleport random players to different locations?

Arqade Asked by user262579 on December 16, 2020

So I am making an adventure map when I ran into a problem that might be impossible to solve with the limitations of bedrock edition.
So what I wanted to know is, can I randomly teleport players to certain positions without the chance of more than 1 player teleporting in the same position?

2 Answers

If you know approximately where everyone is going to be before they are teleported (i.e. a lobby), put some armor stands down, name them something like spawn_0 and a bunch of different ones and then tp them with:

execute @e[type=armor_stand,name="spawn_0"] ~ ~ ~ tp @r[x=5,y=10,z=5,r=30] @s

Have that happen as many as you want, like spawn_1, spawn_2, etc. Obviously adjust r for your needs. Adjust x=, y=, z= to where your lobby/place before people are teleported.

If you don't know where anyone is going to be, you may want to look into the /tag command. This answer should suffice for most situations, though.

Correct answer by Penguin on December 16, 2020

My answer requires no additional entities. You basically want to number players randomly, and teleport them based on their ID. This is useful because you can then target players based on their IDs.

First, you need a scoreboard objective to hold the players’ ID numbers.

/scoreboard objectives add id dummy

And you need a fake player to hold the current ID number.

/scoreboard players set #current id -1

First, set everybody’s ID to -1.

/scoreboard players set @a id -1

Then, repeatedly run the following commands to increment the ID and give a random player that ID:

/scoreboard players add #current id 1
/scoreboard players operation @r[scores={id=-1}] = #current id

Then, teleport players to different locations:

/tp @a[scores={id=0}] 12 23 34
/tp @a[scores={id=1}] 23 34 45

Remember, the first ID is 0, not 1!

Answered by ExpertCoder14 on December 16, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP