Multiple scores from collisions how do I stop after one collsion

I am creating a game that you throw objects at a board and if the object lands on the board you get a score. The problem is when the object hits the board sometimes it bounces or rolls and multiple scores are logged. I would like for only one score to be annotated per throw. Thanks in advance and sorry if this question has been asked before… I looked and could not really find anything similar. Here is the code:`using UnityEngine;
using System.Collections;

public class ID355 : MonoBehaviour
{
public GameObject score; //reference to the ScoreText gameobject, set in editor
public GameObject otherObject;

    void OnCollisionEnter() //if bag hits board
    {
    otherObject.GetComponent<bagDetect>().bagHit = false;
    bool hit = otherObject.GetComponent<bagDetect>().bagHit;
        if (hit == false) 
        {
            int currentScore = int.Parse (score.GetComponent<GUIText> ().text) + 1; //add 1 to the score
            score.GetComponent<GUIText> ().text = currentScore.ToString ();
            otherObject.GetComponent<bagDetect>().bagHit = true;
            print(hit);
        }
            
    }
    
    
    void OnTriggerEnter() //if bag hits collider
    {
        
            int currentScore = int.Parse (score.GetComponent<GUIText> ().text) + 3; //add 3 to the score
            score.GetComponent<GUIText> ().text = currentScore.ToString ();
    }
}

`
and here is the code for otherObject:

using UnityEngine;
using System.Collections;

public class bagDetect : MonoBehaviour {
    public bool bagHit = false;
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
    
    }
}

You can either:

  1. Have a one-shot boolean that stops the score retriggering, as @meat5000 suggested
  2. Use void OnCollisionStay() instead of void OnCollisionEnter() if you have this problem every time a bag hits the board.

I would say the one-shot bool is probably your best option.

Your prefabs become unique objects when instantiated. So you need a flag in the object being thrown prefab code like ‘IsScored’ initially set to false.

Then on collision with the board you check the state of the flag to see if the object was scored. It not scored (e.g. if (!IsScored) then…) then increment the score and set the objects ‘IsScored’ to true. Subsequent collisions of the thrown object will not increment the score.

Note, this scores the first time the object hits the board. So, if it hits the ground (or something else) first and then hits the board is not a score, then you’ll need to set it on any collision vs. just the board collision.

DiaGiaCom,"
Your prefabs become unique objects when instantiated. So you need a flag in the object being thrown prefab code like ‘IsScored’ initially set to false.

Then on collision with the board you check the state of the flag to see if the object was scored. It not scored (e.g. if (!IsScored) then…) then increment the score and set the objects ‘IsScored’ to true. Subsequent collisions of the thrown object will not increment the score."

this is what I did… with the otherObject (otherObject is the code on the prefab)and the first code listed… I understand what you are saying I think I am missing something small with this …