How to disable a boxcollider2d temporary?

hi guys,

So i’m making a game similair to flappyBird and whenever you trough the pipes you get a point. The problem is sometimes my player hits the box twice. it gets two piont instead of one. So i want to disable my boxcollder2d for a second after it gets hit by my player. The boxcollider2d are in a loop so they can’t be disabled forever.

code i used for my collider2d to trigger:

        void OnTriggerEnter2D(Collider2D collider) { 
        if(collider.tag=="Player"){
        PlaySound(0);
        Scores.AddPoint();
    }
}

You could try this: Unity - Scripting API: MonoBehaviour.StartCoroutine

So it’s like:

void OnTriggerEnter2D(Collider2D collider) { 
         if(collider.tag=="Player"){
         PlaySound(0);
         Scores.AddPoint();
         GetComponent<BoxCollider2D> ().enabled = false;
         StartCoroutine(EnableBox(1.0F));
     }

  IEnumerator EnableBox(float waitTime) {
        yield return new WaitForSeconds(waitTime);
        GetComponent<BoxCollider2D> ().enabled = true;
    }

I feel like there is a better option to handle this situation, maybe someone will tell you, but this should work too.