How to Fix NullReferenceException: Object reference not set to an instance of an object (JS)

Hi, I’m really new to coding in JavaScript. I am trying to make a game where you kick a tree (yeah, stupid) and whenever your leg collides with it, it scores a point. But I’m getting this error: NullReferenceException: Object reference not set to an instance of an object

Here is my code for the tree:

 var Counter : int = 0;      
 
 function Update () {    
     textField = GetComponent(UI.Text);
     textField.text = "Score: "+Counter; 
     }   
         
 function React () {            
     Counter++;    
     }

And here is my code for the leg:

 function OnCollisionEnter(theCollision : Collision){
 
    if(theCollision.gameObject.name == "Target"){ 
       gameObject.Find("Score").SendMessage("React");       
       Debug.Log("Score!");  
       yield WaitForSeconds(1);
       gameObject.active=false;
       }
 }

So what is the problem? Thank you.

To begin with, Find() is not a function of gameObject, but instead of GameObject (with a capital G). So replace gameObject.Find("Score") with GameObject.Find("Score")

If that doesn’t work, can you tell me what script and line the problem is being made in?