Hey guys I need help for a score broad system.

Hey guys I need help for a score broad system for my school project. My problem is that I have c sharp coding on my ball and once you score the ball the ball will teleport to its original ball position , and that’s great, but it will also give both players a point and that’s where i’m struggling to fix if you can lend me a hand that would be great.

using UnityEngine;
using System.Collections;

public class BallManager : MonoBehaviour
{

public int Score1;
public int Score2;
public void OnTriggerEnter(Collider other)
{
    //		if  (other.gameObject.tag -- "Goal1")
    {
        transform.position = GameObject.Find("BallPosition").transform.position;
        //			this.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
        Score1 += 1;
    }
    //        if (other.gameObject.tag-- "Goal2")
    {
        transform.position = GameObject.Find("BallPosition").transform.position;
        //			this.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
        Score2 += 1;
    }
}

public void Update()
{
    GameObject.Find("Score1").GetComponent<TextMesh>().text = Score1 + "";
    GameObject.Find("Score2").GetComponent<TextMesh>().text = Score2 + "";
}

}

@nuckolls Would this help you?

  using UnityEngine; using System.Collections;
    
    public class BallManager : MonoBehaviour {
    
     public int Score1;
     public int Score2;
    
     public void OnTriggerEnter(Collider other)
     {
                if  (other.gameObject.tag  == "Goal1")
         {
              this.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
             transform.position = GameObject.Find("BallPosition").transform.position;
    
             Score1 += 1;
         }
            if (other.gameObject.tag == "Goal2")
         {
              this.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
             transform.position = GameObject.Find("BallPosition").transform.position;
             Score2 += 1;
         }
     }
     public void Update()
     {
         GameObject.Find("Score1").GetComponent<TextMesh>().text = Score1 + "";
         GameObject.Find("Score2").GetComponent<TextMesh>().text = Score2 + "";
     }
    }

Other checks to make sure it should work:

  1. Are your object names the same as in your script?
  2. Are you putting this script in the ball itself?
  3. Have you “Tagged” your objects correctly?

Thank you madskillzHD for the script and the help and yes I had everything tagged correctly.