a little help on scripting

the error is:

(6,17): BCE0044: expecting :, found ‘-=’.

static var enemy = 5;

function Update () {

}

{

      enemy -= 1; //this variable hasn't been declared.

}

{

if (enemy
}

}

The reason that is not working is you need that line to be in a function:

static var enemy = 5;

function Update () {
    enemy -= 1;
    if (enemy != 0) 
    {
    }
}

If this script is complete, it’s totally wrong - specially the if statement: you should change the } after enemy to a ). What’s this script supposed to do?

I dont know much about JavaScript, mainly beeing a C# developer but for something like this i belive i can help.
I belive what you are trying to archieve is something like this:

static var enemy = 5;

function Update () {
    if (enemy > 0) 
    {
       //place here the code to run while there are still enemies
    }else
       {
          //here goes the code for when you run out of enemies.
       }    
     enemy -= 1;
}

Still there is a problem with the overall idea of this code, because the Update() function runs every frame. So you will literaly run out of of enemies in 5 frames. Given that a game usualy runs somewhere around 40 to 100 frames per second… you will allways almost instantly run out of enemies before anything can happen. =)

Maybe you can tell us what your goal is so we can better try to help? =)