# Question about keeping score / defining a winner

**URL:** <https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247>\
**Category:** Uncategorized\
**Created:** [January 14, 2003, 3:15pm UTC](https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247 "2003-01-14T15:15:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PressIntent](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@PressIntent](https://forum.kirupa.com/u/PressIntent)\
**Post date:** [January 14, 2003, 3:15pm UTC](https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247/1 "2003-01-14T15:15:40Z")

</div>

I’ve made a game where you click on different floating objects to get different point amounts. I have a dynamic text box that has a variable set to score and then when the user presses the floating objects it adds points to the score.

That all works fine, but now I need an action so that  
when the score reaches 100 it proclaims you as the winner.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 14, 2003, 3:57pm UTC](https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247/2 "2003-01-14T15:57:38Z")

</div>

```auto

if (score>=100){
	_root.gotoAndStop (#);
}

```

[SIZE=3] **#** [/SIZE] = number of the frame with the message: **You Win!**

🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 14, 2003, 4:08pm UTC](https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247/3 "2003-01-14T16:08:16Z")

</div>

Thanks for your help!

Unfortunately I tried putting the code

if (score\>=100){  
\_root.gotoAndStop (2);  
}

on frame one of the movie (it’s only 2 frames long) and when I rack up to 100 it still doesn’t go on to frame 2. Any ideas as to why?

They way I’m adding points is with an action attatched to a button that says

on (release) {  
\_root.score = \_root.score +5;  
}

is there something wrong with that?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 14, 2003, 4:24pm UTC](https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247/4 "2003-01-14T16:24:56Z")

</div>

yeah, dont put it in the frame, put it in the button since that is being used to alter score:

on (release) {  
\_root.score = \_root.score +5;  
if (score\>=100){  
\_root.gotoAndStop (2);  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 14, 2003, 4:53pm UTC](https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247/5 "2003-01-14T16:53:12Z")

</div>

sen is right.

That happens cause the if condition in the frame doesn´t keep updating itself, it checks once (in the beggining) and the score is lower than 100, so it doesn´t do anything but when it reaches 100 the condition isn´t checking again.

You can place it on the **on (release)**, of the button, like sen told you to do, and every time the button is released the condiditons is checked again.

🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 14, 2003, 5:01pm UTC](https://forum.kirupa.com/t/question-about-keeping-score-defining-a-winner/11247/6 "2003-01-14T17:01:53Z")

</div>

if you want to do it by frame, you can be a ‘good’ mx programmer and use object.watch 🙂

```auto

onNewScore = function(){
	if (this.score >= 100) this.gotoAndStop(2);
	return arguments[2];
}
_root.watch("score", onNewScore);

```

since you are ‘watching’ the score value in \_root, you call watch from root and include “score” (variable to watch) and the function to be run whenever that variable changes, which in this case is onNewScore. onNewScore checks the score and sees if its over 100, and it it is, goes to frame 2. The return arguments[2]; just keeps the score from changing (since watch lets the onNewScore function change that value should it need to with a return argument, if you dont want to change it, just return arguments[2] which is the value it was changed to when this was called in the first place)
