How do I define collision conditions but harder

how do I make a line of code in the following conditions:

  1. the camera touches a cuboid, then the cuboid moves.
  2. problem: how do I make the cuboid STOP MOVING when the camera is NOT COLLIDING WITH THE CUBOID?