Script not working to destroy an object

Hi guys,

im having a problem with my script, Unity keeps telling me BCE0044: expecting (, found ‘OnTriggerEnter’. I am following along with a book and doing exactly what they say but it doesnt seem to want to work. heres the code

#pragma strict

public var shotspeed : float = 5.0;

function Update () {

	{
		transform.Translate (0, shotspeed * Time.deltaTime, 0);
	}
	
	function OnTriggerEnter (other: Collider) {
		if (other.tag == "terrain")
			{
			Destroy (gameobject);
			}
		}
	}

Thank you for any help you could give.

Oh its okay you just made a simple mistake everyone does this once in a while. You made the OnTriggerEnter function inside of the update function. Here iss the fixed code:

public var shotspeed : float = 5.0;
 
function Update () {
        transform.Translate (0, shotspeed * Time.deltaTime, 0);
}
function OnTriggerEnter (other: Collider) {
      if (other.tag == "terrain")
     
      Destroy (gameobject);
      }
   }
}