Collider trigger two times, even if it's not active.

I have simple coin counter, in 2d Unity game. But It’s count one coin as 2. If we look in to logs, we cant see that they work twice, when it’s even not enabled.

    public GameObject coin;
    public Text CoinCounter;
    private int TotalCounter = 0;
    public BoxCollider2D collider;
   

    // Start is called before the first frame update
    void Start()
    {
        int.TryParse(CoinCounter.text, out TotalCounter);
        Debug.Log("Counter on Start :" + TotalCounter);
        Debug.Log("Text o");

    }

    private void Update()
    {
           TotalCounter = Convert.ToInt32((CoinCounter.text));
     }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        collider.isTrigger = false;

        if ((collider.isTrigger) == false)
        {
            Debug.Log("Collider Is not Trigger");
        }else
        {
            Debug.Log("Collider is still trigger");
        }
      
    
        Debug.Log("Trigger Entered");

        coin.SetActive(false);

        Debug.Log("Object is not active ");
        
        TotalCounter += 1;
        Debug.Log("Total Counter + :" + TotalCounter);
        CoinCounter.text = TotalCounter.ToString();
        Debug.Log("Text after +:" + CoinCounter.text);
   
    }
}
![133581-logs.png|1485x532](upload://1EikG99Htfsg4VOSZGdLUog9jYc.png)

The Unity OnTriggerEnter2D can be a bit buggy and occasionally run twice, though you may want to check you haven’t put multiple trigger colliders on either the player or the coin, as it will be running for each collision. A simple Workaround if that’s not it would be to check if the coin is enabled before disabling it and adding to the coin counter. Eg:

 if (coin.activeSelf)
     {
         coin.SetActive(false);
 
         Debug.Log("Object is not active ");
         
         TotalCounter += 1;
         Debug.Log("Total Counter + :" + TotalCounter);
         CoinCounter.text = TotalCounter.ToString();
         Debug.Log("Text after +:" + CoinCounter.text);
     }