# If statement help

**URL:** <https://forum.kirupa.com/t/if-statement-help/194108>\
**Category:** Uncategorized\
**Created:** [July 20, 2006, 4:42pm UTC](https://forum.kirupa.com/t/if-statement-help/194108 "2006-07-20T16:42:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaggieBroon](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@MaggieBroon](https://forum.kirupa.com/u/MaggieBroon)\
**Post date:** [July 20, 2006, 4:42pm UTC](https://forum.kirupa.com/t/if-statement-help/194108/1 "2006-07-20T16:42:13Z")

</div>

Hi guys!

I’m looking for a wee bit of help for a game I’m doing if someone could spare me a minute?  
Basically, its a gambling game of chance and I want it to go to a random frame which will play a movie when the button “one” or the button “two” is pressed.

so on each button, I have the code:

```auto
on(release){
	myChoice = "one";
//pick a random frame to land on
	var maxChoice = 3;
	var n = Math.ceil(Math.random()*maxChoice);
	_root.gotoAndPlay(n+2);
}

```

The variable “one” is “two” on button two, but its the same code other than that.

So it picks a random frame to go to, plays the movie, and at the end of it, I want it to pick either win or lose depending on whether what button the person presses is the same as the random movie which has played. So on the last frame of each movie(code varies for each different outcome), I put this:

```auto
stop();
if(myChoice="two"){
	_root.gotoAndPlay("lose")
}

if(myChoice="one"){
	_root.gotoAndPlay("won")
}

```

I just dont ‘get’ it. Every time I publish it, it always goes to whatever **if** statement is at the top rather than actually deciding whether it was right or not. So if I swap them round, it just goes to the “won” frame.

Sorry for a rather long-winded explanation for something that is probably very simple!

Thanks in advance x
