So I am new to unity and I want water to kill the player and send the player back to the title screen. Here is the script.

private var dead = false; //Setting the Varible
 
function OnControllerColliderHit(hit : ControllerColliderHit) { 
    if(hit.gameObject.tag == "Water") //Hiting the water Kills
{ 
        dead = true; 
}
 
function LateUpdate(){
    if(dead) //If Your dead
    {
        Application.LoadLevel(0)
        dead = false;
    }
}

I keep getting this error “Expecting (, found LateUpdate”

I dont know what this means… Please help me out!

Also I want to create a script so it looks like the Player is dying. As long as I’m here, I am wondering if it will work.

if(dead)
{
	var duration = 5.0; // fade duration in second
  // create a GUITexture:
  var fade: GameObject = new GameObject();
  fade.AddComponent(GUITexture);
  // and set it to the screen dimensions:
  fade.guiTexture.pixelInset = Rect(0, 0, Screen.width, Screen.height);
  // set its texture to a black pixel:
  var tex = new Texture2D(1, 1);
  tex.SetPixel(0, 0, Color.black);
  tex.Apply();
  fade.guiTexture.texture = tex;
  // then fade it during duration seconds
  for (var alpha:float = 0.0; alpha < 1.0; ){
    alpha += Time.deltaTime / duration;
    fade.guiTexture.color.a = alpha;
    yield;
  }
}

The function OnControllerColliderHit is not ended properly.

Insert } at line 9 in the first section of code