How to desible a object if a certain condition is meet ?

Hello can anyone help me with this i just stuck here ! i want to disible the door after all the cube is destroyed so what i can do plz help me someone . thank you

if (yourGameObjectName == null)

can i use tag cause ther was 7 cubes

Since you dont need the door anymore after you found the cube you can just Destroy(door). Just set the cube collision to destroy the door and than the cube when OnCollisionEnter()