OnTriggerEnter not detecting tag

I have this code for turning on and off certain scripts upon trigger enter but instead of it only working on trigger enter it runs through the script without a trigger entry. I believe it’s not detecting that I am asking for it to look for a tag. Any idea’s why? (Unity4 Question, Javascript)

#pragma strict

function Start(){
	
}


function OnTriggerEnter (trigger:Collider) 

{
	if(trigger.gameObject.tag=="Player");
{

	 (GameObject.FindWithTag("Player").GetComponent( "show_hidecursor_lost_forest") as MonoBehaviour).enabled = false;
     (GameObject.FindWithTag("Player").GetComponent( "simplepause_lost_forest" ) as MonoBehaviour).enabled = false;	 

     
    } 
}	
	
function OnTriggerExit (trigger:Collider)
{

	if(trigger.gameObject.tag=="Player"); 
{
	
	 (GameObject.FindWithTag("Player").GetComponent( "show_hidecursor_lost_forest") as MonoBehaviour).enabled = true;
     (GameObject.FindWithTag("Player").GetComponent( "simplepause_lost_forest" ) as MonoBehaviour).enabled = true;

    }
}

Try to use this :slight_smile:

  1. function OnTriggerEnter(trigger:Collider)
  2. {
  3. if(trigger.collider.gameObject.tag == “Player”)
  4. {
  5. //Your code here
  6. }
  7. }

Hey! The problem is that you have a semicolon after your if-statements on lines 11 and 24. Removing those should make the code work properly.