how do i enable the box collider after disabling with this script?? dont know why but cannot enable the collider back once disabled.

using UnityEngine;

public class PassageAllowance : MonoBehaviour
{
    public BoxCollider blockage;
    public bool flag;

    void OnCollisionEnter(Collision collisionInfo)
    {
        if (collisionInfo.collider.tag == "ball")
        {
            flag = true;
            blockage.enabled = false;
        }    
    }

    void Update()
    {
        if (flag == true)
        {
            blockage.enabled = true;
            flag = false;
        }
    }
}

You have to do something like this:

     void OnCollisionExit(Collision collisionInfo)
     {
         if (collisionInfo.collider.tag == "ball")
         {
             flag = false;
             blockage.enabled = true;
         }    
     }

and take out that Update function.

I’m not sure if how you currently have everything setup if this will work, but you might want to try just this instead:

void OnCollisionStay(Collision collisionInfo)
     {
         if (collisionInfo.collider.tag == "ball")
         {
             flag = true;
             blockage.enabled = false;
         }
         else
         {
              flag = false;
              blockage.enabled = true;
         }
     }

and with that you might not need anything else so you wouldn’t need that OnColliderExit or update function.

I don’t have an IDE, have not tested with Unity, and don’t know why you need to disable and enable the colliders, so if neither of those solutions work please let me know and I will assist further.