0

So we already know I have an anarchy world and I want to "troll" some players with a command block with a simple goal.

"One the button is pressed, you will be teleported in a random area, and maybe you can make your base there."

So unlike here, I want to set up a /tp on the command that kinda goes like this:

/tp @p [rand=100000,-100000] 255 [rand=100000,-100000] true

Now I'm thinking of setting the coordinates to a random int without adding a mod or some additional code (because I don't know how to add it in or make one even though I'm a programmer).

Is it possible to set random numbers in a teleportation command in Bedrock Edition?

10
  • 1
    Please don't assert that what you are asking for is possible. Minecraft has never had good support for randomness, and Bedrock Edition has a very restricted command format. It's hard enough to accomplish your task in Java Edition, let alone in Bedrock. So if you aren't 100% sure that what you're asking for is possible, please fall back to asking "is it possible" rather than "how to do it". – ExpertCoder14 Jan 31 at 19:03
  • @ExpertCoder14 I mean... does that phrasing really make that much of a difference? – Penguin Jan 31 at 19:27
  • 1
    Just use the /spreadplayers command, it would be more customizable anyway – Penguin Jan 31 at 19:27
  • @Penguin Yes. The original phrasing basically brings up the tone that they won't accept a "that's impossible" answer. When you ask "is it possible," it tells others that you're open to the fact that what you're asking for may not be possible. – ExpertCoder14 Jan 31 at 19:29
  • @ExpertCoder14 It really isn't as big of a deal as you are making it. Just edit the post, write what you are editing in the log, and go about your day. – Potterton Jan 31 at 20:07
5

Use the /spreadplayers command:

spreadplayers <x: value> <z: value> <spreadDistance: float> <maxRange: float> <victim: target>

X and Z is the center of the range in XZ-plane you wish to start the spread. Spread distance is irrelevant if only randomly placing a single player (it's the minimum distance a player must be placed away from other players) and can be 0. Max range is the maximum distance away from the XZ center the player is to be randomly placed. victim is any selector and in bedrock can apply to any entity, not just players.

As for general randomness for selectors, there isn't a direct syntax to apply random numbers, but you can use the random player selector (@r) anywhere you need an entity selector so long as you specify 'type' with the selector. For example /kill @r[type=zombie] kills a random zombie.

1
  • Nice command. Looks like my game crashed, but I enjoyed it. I guess it helps, just not the way I expected. – Mark Giraffe Feb 1 at 8:05

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.