BCE0044 expecting :, found '='

so i was following a tutorial and I needed the cube to measure the distance from the cube to the player but for some reason i got the BCE0044 error. This is my code:

playerDistance = Vector3.Distance(player.transform.position, transform.position);
	if (playerDistance <= 2){
		if (!attacking){
			Invoke("ApplyDamage" , 3);
			attacking = true;

Without seeing the rest of the code it might be tricky to pin-point, but from what I can see there is only one closing bracket for two if-statements.

after looking at several other questions mentioning this same error link text I would suspect that the error is actually the line directly above the one you are pointing to.

the cases I saw that give this result are:

  • having to many braces (this coding practice has never made any sense to me.

    if(foo == true){

         //do stuff


  • not closing all braces that have been opened

    if(foo == true){

     /*do stuff*/

    // then do stuff outside of the if

  • though this can also show up from using a semicolon in the wrong place.

it would appear that all these errors are directly linked to UnityScript being interpreted where the “:” operator can be placed at the end of the line meaning that the interpreter expects it at the end of every line. and the best I can glean is that any time you see a BCE0044 just look above the line it is pointing to.