An other why “; expected. Insert a semicolon at the end“ sorry,

Hi, i know it is a frequently asked question, but i am a lost beginner. I have this (22,13): UCE0001: ‘;’ expected. Insert a semicolon at the end. and i don’t understand, i have already a semicolon on this line.

#pragma strict

var animator : Animator;
animator.SetBool("Punching", false);

function Start () 
   {
   animator = this.GetComponent(Animator);
   }

function Update () 
   {

   if (Input.GetKeyDown(KeyCode.G)) 
      {
       animator.SetBool("Punching", true);
       StartCoroutine("StopAnimation");
      }

   IEnumerator StopAnimation()
      {
       yield return new WaitForSeconds(0.5);
       anim.SetBool("Punching", false);
      }

   }

Can you help me please, thanks in advance!

Move the line 4 animator.SetBool("Punching", false); somewhere else inside a function (Start?) or delete it completely and set the parameter “Punching” to false in the editor.

Also, Line 23 accesses a variable “anim”. Maybe you meant “animator”?

Edit: Finally, Line 22 uses the syntax for C# yields. (“yield return new WaitForSeconds”). The syntax for UnityScript is “yield return WaitForSecond…”. (No need to use the new operator in UnityScript).

Edit Edit: Aaand spotted another error: Look where your Update function starts and where it ends. Your function “StopAnimation” is inside the Update function. That is not legal in neither UnityScript nor C#. You have to close Update() first and then start the StopAnimation function.