FadeOut when enter Collider errors.

I want to make the screen fade out when my car hits a invisible wall. This is my script, but I get errors…

#pragma strict

private var theCollider : String;
private var alpha = 1.0; 
private var fadeDir = -1;

var fadeTexture : Texture2D;
var fadeSpeed = 0.2;
var drawDepth = -1000;


function OnTriggerEnter (other : Collider)
{
	theCollider = other.tag;
	if (theCollider == 'Player')
	{
		// FadeInOut

function OnGUI(){
 
    alpha += fadeDir * fadeSpeed * Time.deltaTime;  
    alpha = Mathf.Clamp01(alpha);   
 
    GUI.color.a = alpha;
 
    GUI.depth = drawDepth;
 
    GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeTexture);
}

//remember to set up the 2d texture / fadespeed / drawDepth.

You cannot nest function calls like this (OnGUI() inside of OnTriggerEnter()). You need to do something like:

#pragma strict

private var theCollider : String;
private var alpha = 1.0; 
private var fadeDir = -1;
 
var fadeTexture : Texture2D;
var fadeSpeed = 0.2;
var drawDepth = -1000;

private var fade = false;
 
function OnTriggerEnter (other : Collider)
{
    theCollider = other.tag;
    if (theCollider == 'Player')
    {
       fade = true;
      
	}
}

function OnGUI(){
	if (fade)
	{
		alpha += fadeDir * fadeSpeed * Time.deltaTime;  
		alpha = Mathf.Clamp01(alpha);   
		
		GUI.color.a = alpha;
 
		GUI.depth = drawDepth;
 
		GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeTexture);
	}
}