# How do I create random percent scenarios

Get help using Construct 2

### » Mon Sep 01, 2014 11:49 am

For example I have two scenarios X and Y.
When a button is pushed I want it so X pops up on the screen 80 percent of the time when the other 20 Y pops up.
B
9
S
3
G
2
Posts: 53
Reputation: 1,789

### » Mon Sep 01, 2014 11:56 am

something like
IF random(100) < 80 do X
ELSE do Y
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Mon Sep 01, 2014 12:07 pm

Thanks I tried it, kinda worked, but I want to do something like SetText: X 80 percent of the time and Y 20 percent (it is not a condition but an action so can not do else)
B
9
S
3
G
2
Posts: 53
Reputation: 1,789

### » Mon Sep 01, 2014 1:01 pm

You could use the choose() expression..

choose(x,x,x,x,y) should make 20% chance of y against 80% chance of x
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Mon Sep 01, 2014 1:14 pm

@Tombufa

Use conditional expressions (essentially an if/else)

For example,
Set Text: random(100)<80 ? "" & X : "" & Y
Find all the Construct 2 games that were on Steam Greenlight here
B
42
S
11
G
7
Posts: 513
Reputation: 7,355

### » Tue Sep 02, 2014 12:10 pm

thankyou everyone it now works
B
9
S
3
G
2
Posts: 53
Reputation: 1,789

### » Tue Sep 02, 2014 1:22 pm

This was asked before, solution with capx if you still need them. Cheers!
B
28
S
8
G
4
Posts: 553
Reputation: 4,944