Arqade Asked by Robert Lucas on December 29, 2020
I need a random number from -100 to 100 for a command block
/tp @p (random number 1) 200 (random number 2)
As far as I know, there is no way to directly generate a random number using commands, and there definitely isn't any way to then plug that random number into another command block.
However, the spreadplayers
command will do what you're after here. spreadplayers
is designed to place groups of, or individual players, in random spots around the map.
The syntax is as follows for Java Edition: /spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player>
. <x> <z>
specifies the center of the map, <spreadDistance>
specifies the minimum distance between the targets, <maxRange>
specifies the maximum horizontal distance to place players from the center, <respectTeams>
specifies whether or not teams should be kept together, and <player>
specifies your targets.
In the particular case of sending a single @p
to some location between x,z (-100,-100) and (100,100), the command would look like so:
/spreadplayers 0 0 0 100 false @p
Correct answer by Unionhawk on December 29, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP