1

What is the most efficient way to get a random output with my commands? In Java there are tons of ways to do this, but a lot of them don’t seem to work for Bedrock Edition.

0
1

Concept

The @r selector can be used to pick a random player. What some people do not know, though, is that if you specify another type other than player you can have it select things other than players.

Commands

Lets say I want to have my machine output white or black wool. We have 2 command blocks with a tick delay of 7 (if we don’t have a tick delay it will sometimes fail) with the command:

setblock ~ ~1 ~ air

Now chains attached to them with these (one will be white, one black):

setblock 5 5 5 wool 0

and

setblock 5 5 5 wool 14

Now above the original impulse command have air and a block above that bedrock with armor stands on top of each. Name the armor stands the same thing. I will use test.
Now somewhere else have a command block that says:

execute @r[type=armor_stand,name=“test”] ~ ~ ~ setblock ~ ~-2 ~ redstone_block

Now when that command block is activated, it will place either a white or black wool block at 5, 5, 5!

0
1

@r is an obsolete method. It is really only effective for up to 10 outputs.

The standard way to get a random output in Bedrock Edition is /scoreboard players random, an MCBE only command.

Syntax:

scoreboard players random <player: target> <objective: string> <min: int> <max: int>

This will set a scoreboard number to a random value between min and max.

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.