Having a 50-50 chance apply to commands [duplicate]

Having a 50-50 chance apply to commands [duplicate] - Positive dirty ethnic child applying flour on face of young crop parent while having fun in kitchen and looking at each other

I'm creating a game and I need a fill command to have a 50-50 chance of opening one of two gates (Ex. This will be activated when a button is pressed to start game). The obvious choice would to use the @r selector, but I don't know how to apply this to a command block command.

I'm running 1.10.2 and this is only a two player game. (For me and a friend)



Best Answer

You can use a "random" number generator by periodically changing the value of a objctive on a fast redstone clock:

(First create the objetcive by /scoreboard objectives add FiftyFifty dummy)

 /scoreboard objectives set @a FiftyFifty 0

 /scoreboard objectives set @a FiftyFifty 1

So the FiftyFifty objective is 50% of the time equal to 1. To trigger your command, you need to constantly run this command (in a repeat command block):

/testfor @a[score_FiftyFifty_min=1]

And if this command returns true, ecexute your command (in a Chain command block)




Pictures about "Having a 50-50 chance apply to commands [duplicate]"

Having a 50-50 chance apply to commands [duplicate] - Unhappy Woman Crying at Home
Having a 50-50 chance apply to commands [duplicate] - King Chess Piece
Having a 50-50 chance apply to commands [duplicate] - Person About to Catch Four Dices





BEST WAY TO GET LIMITED 5 STAR CHARACTERS!? ⭐ Genshin Impact Wish Guide to 50/50 \u0026 Pity




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Any Lane, Karolina Grabowska, Gladson Xavier, lilartsy