Score counter out of control, help needed.

I've implemented a scoring system to which will add 10 points per target being destroyed. The problem being is that the minute I start playing the game the scoring system continuously goes up without even needing to destroy targets (see video).

The scoring system comes to a halt prior to the last target being destroyed.

I have this script linked to gui text:

static var points = 0.0; // A static var can be acessed form other scripts. 

function Update ()
{
//assuming that you want the score on a guiText.

guiText.text = "Score" + points;
}

And this attached to the targets to be destroyed:

var pointsToAdd = 10; // You will add 10 points for each kill.

function Update() 
{PointManager.points += pointsToAdd;
}

If anyone could assist me in correcting this problem i'll forever be in debt, much thanks!

Video (imageshack upload): link text

All your targets are adding 10 points per frame without any condition...

I guess you want to add 10 points when the object gets destroyed. You could use the destructor of your script but it will have an unpredictable delay due to the garbage collector.

The best way would be to add the points in `OnDisable()`.

var pointsToAdd = 10; // You will add 10 points for each kill.

function OnDisable() 
{
    PointManager.points += pointsToAdd;
}