I’m having trouble figuring out how to add a scoring count so that, from the first roll of the dice up until it reaches 40 or goes over it’ll keep the score and add the amount from each roll. Any suggestions?

``````
function throwdice()
{
var die1name;
var die2name;
var die3name;
var die4name;
var total;

die1 = 1 + random(6);
die2 = 1 + random(6);
die3 = 1 + random(6);
die4 = 1 + random(6);

removeMovieClip (moving1);
removeMovieClip (moving2);
removeMovieClip (moving3);
removeMovieClip (moving4);

die1name = "seed" + die1;
die2name = "seed" + die2;
die3name = "seed" + die3;
die4name = "seed" + die4;

duplicateMovieClip(die1name, "moving1", 11);
moving1._x = 69.5;
moving1._y = 184.5
moving1._rotation = random(80);
duplicateMovieClip(die2name, "moving2", 12);
moving2._x = 155.5;
moving2._y = 184.5
moving2._rotation = random(80);
duplicateMovieClip(die3name, "moving3", 13);
moving3._x = 251.5;
moving3._y = 184.5;
moving3._rotation = random(80);
duplicateMovieClip(die4name, "moving4", 14);
moving4._x = 337.5;
moving4._y = 184.5;
moving4._rotation = random(80);

moving1.gotoAndPlay(1);
moving2.gotoAndPlay(1);
moving3.gotoAndPlay(1);
moving4.gotoAndPlay(1);
total = die1 + die2 + die3 + die4;
if (_root.firstthrow == true)
{
_root.outcome = "";
_root.pointvalue = "";
if (total <= 40 )
{
_root.outcome = "You Win";
}
else if (total >= 39)
{
_root.outcome = "You Lose";
}
else
{
_root.firstthrow = false;
_root.pointvalue = total;
}
}
else if (total == _root.pointvalue)
{
_root.outcome = "You Win";
_root.firstthrow = true;
}
else if (total >= 40)
{
_root.outcome = "You Lose";
_root.firstthrow = true;
}
}
function setvalues()
{
_root.die1valued = _root.die1;
_root.die2valued = _root.die2;
_root.die3valued = _root.die3;
_root.die4valued = _root.die4;
_root.pointvalued = _root.pointvalue;
_root.outcomed = _root.outcome;
}
function clearvalues()
{
if (_root.firstthrow)
{
_root.pointvalued = "";
}
_root.die1valued = "";
_root.die2valued = "";
_root.die3valued = "";
_root.die4valued = "";
_root.outcomed = "";
}

var firstthrow = true;
var pointvalue;
var die1;
var die2;
var die3;
var die4;
var outcome;

``````

anybody?

Make a dynamic text with a var name of Score.

And then have _root.Score += total

When you restart just do _root.Score = 0. If that doesn’t work try taking away _root and/or making Score have an instance name or linkage name of Score.