OnTriggerEnter Problem

Hi Guys im sorry to bother you with my question, but I haven´t found a solution yet.
I´m currently working on a Mobspawn Skript with Java

#pragma strict


var Spawn = false;


function Update () 
{

function OnTriggerEnter (theCollider : Collider)
	{	
		if (theCollider.tag == "Player")
		{
			Spawn = true;
		}
	}

	
function OnTriggerExit (theCollider : Collider)
	{
		if (theCollider.tag == "Player")
		{
			Spawn = false;	 	
		}
	}
}

So my idea was to create an empty object wich Spawns Enemys as long as the Players collision box collides with the empty´s collison box until a certain number of mobs is reached.

I´ve checked it a hundred times by now and compared it to similiar scripts which work. But still im getting the following Errors:

alt text

Assets/Enemyspawn.js(10,10): BCE0044: expecting (, found ‘OnTriggerEnter’.
Assets/Enemyspawn.js(10,26): BCE0043: unexpected token: theCollider.
Assets/Enemyspawn.js(10,49): UCE0001: ‘;’ expected. insert a semicolon at the end.
Assets/Enemyspawn.js(12,17): BCE0043: unexpected token: if.
Assets/Enemyspawn.js(12,49): UCE0001: ‘;’ expected. insert a semicolon at the end.
Assets/Enemyspawn.js(10,10): BCE0044: expecting :, found ‘=’.

When you’re checking the tag of the hit:Collider you need to reference to the gameObject first. Right now, you’re asking for the tag property of the Collider.

theCollider.gameObject.tag == "Player"

That should give you what you need.

function Update ()
{

function

There’s you problem. Put your trigger functions outside Update().

Okay now i get it thanks =)