How do I teleport everyone to a random position along with the world border?
I'm trying to make a minigame type thing. When the game starts, I want to teleport everyone to the same random position in the world and have the world border appear around them. Currently I can move an armour stand to a random spot with
/spreadplayersand then I set that as the world border center and then kill everyone.
That works but only if I set the range to like 100 and I want it at like 10000000.
How do I fix this issue or do it in another way?
Your problem is probably because the chunk that the armor_stand is in isn't loaded by a player. You could fix that issue by affecting a player instead.
I made this command sequence that does what I think you want:
You would simply power the bottom command block once. The first command:
execute as @r run tag @s add spread
Adds the tag
spreadto a random player.
execute as @a[tag=spread] at @s run spreadplayers ~ ~ 1 10000000 true @s
Spreads that player somewhere within 10000000 blocks, using the tag to target the player.
execute as @a[tag=spread] at @s run worldborder center ~ ~
Sets the world border center where that player is.
execute as @a[tag=spread] at @s run worldborder set 100 0
Sets the border size.
You could also add a fifth command with:
execute as @e[tag=spread] run tag @s remove spread
To remove the spread tag, if you'd like to repeat the command then this will make it so no more than one player has the tag because it is removed at the end.
If you'd like to tp all players instead of killing them you could use:
/execute as @a[tag=!spread] run tp @a[tag=spread]
This would need to come before the tag-remove command, otherwise, there would be no one with the tag.