Multiple OnTrigger Enter

Hello Everyone,

I’m trying to make a multiple OnTriggerEnter for a race. There is the starting point that triggers a timer when the player enter it and it stops when the player enter the end trigger.

Unity tells me I have syntax errors, but I don’t understand where … Can you help please ?

Thanks in advance

my script :

var finished : boolean = false;
    var winningPicture:Texture;
    var timer:UnityEngine.UI.Text;
    var raceTime:float=0.0;
  
  
    function OnTriggerEnter(col: Collider)
      
        {
        if (col.name == "EndTrigger")
  
            {
                Debug.Log("Congratulation !");
                finished = true;
            }
  
            function OnGUI()
            {
                if (finished)
                {
                    GUI.Label (Rect(Screen.width/2 - 232, Screen.height/2 - 50, 464, 100), winningPicture);
                    if (GUI.Button (Rect (10,50,300,40),"Restart Game"))
                    {
                        Debug.Log ("Restart button was pressed");
                        Application.LoadLevel ("La peur du vide_scene");
                    }
                }
      
            }
  
            function Update()
            {
                if (!finished)
                    raceTime = raceTime+1*Time.deltaTime;
  
                timer.text = raceTime.ToString("f2");
  
      
            }
        else if (col.name == "StartTrigger")
  
          
            function Update()
                {
                raceTime = raceTime+1*Time.deltaTime;
  
                }
          
        }

Your first error is at Line 40
I’m not quiet familiar with UnityScript, but is a function within a function permitted?

Generally it is a big help to post the error, so that we can see what and at what line something goes wrong.
In this case, the whole code is a mess. You can’t define a function within a function. And there can only be one Update method.
And at line 40 you have an else if without a corresponding if case and no brackets.