# Scoring

**URL:** <https://forum.kirupa.com/t/scoring/57643>\
**Category:** Uncategorized\
**Created:** [July 14, 2004, 11:40pm UTC](https://forum.kirupa.com/t/scoring/57643 "2004-07-14T23:40:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![worm](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/worm/32/235_2.png) [@worm](https://forum.kirupa.com/u/worm)\
**Post date:** [July 14, 2004, 11:40pm UTC](https://forum.kirupa.com/t/scoring/57643/1 "2004-07-14T23:40:32Z")

</div>

I used the code i found here  
[http://www.kirupa.com/developer/mx/score.htm](http://www.kirupa.com/developer/mx/score.htm)  
to create some simple scoring.  
It works fine but when i drop it on a fla im working on, the text box thats supposed to show the score displays the text ‘NaN’ instead of the score.  
What could possibly be wrong.

heres the original code

```auto
on (release) { _root.total = _root.total + 100; }

```

and heres what i edited it to be (im doing some drag and drop stuff

```auto
on (release) {
		stopDrag();
		if (this._droptarget=="/male") {
		setProperty(this, _x, 306.0);
		setProperty(this, _y, 65.0);
		_root.sob.gotoAndPlay ("happy");
                 _root.total = _root.total + 100
	}

```

This code is on a button by the way

---

<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:** [July 16, 2004, 8:26am UTC](https://forum.kirupa.com/t/scoring/57643/2 "2004-07-16T08:26:16Z")

</div>

have you tried changing the var field in the text box to _\_root.total_ because otherwise there is no change to the variable in your updated code…

Prophet.

---

<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:** [July 16, 2004, 6:45pm UTC](https://forum.kirupa.com/t/scoring/57643/3 "2004-07-16T18:45:50Z")

</div>

the first action you should have is to set the variable to 0:

```auto
total = 0;

```

now you can add 100 units every time you want:

```auto
on (release) {
		stopDrag();
		if (this._droptarget=="/male") {
		setProperty(this, _x, 306.0);
		setProperty(this, _y, 65.0);
		_root.sob.gotoAndPlay ("happy");
                 total+=100;//here we add 100
	}

```
