on collision stop transform.translate

As title says, I have a scrolling camera but when camera box collider hits otherobject i’d like it to stop movment, but i’m nto entirely sure how to go about this, any ideas would be great.

var speed : float = 0.5;
 
function Update () {
 transform.Translate(Vector3(0,speed,0) * Time.deltaTime);
}

function OnTriggerEnter(otherObject: Collider){
if(otherObject.gameObject.tag == "cameracollision"){
     transform.Translate(Vector3(0,0,0));
}
}

Thank you

You would define a flag that prevents the object from moving, i.e. like this:

var speed : float = 0.5;
var shouldMove : boolean = true;

function Update () {
  if (shouldMove) {
    transform.Translate(Vector3(0,speed,0) * Time.deltaTime);
  }
}

function OnTriggerEnter(otherObject: Collider){
  if(otherObject.gameObject.tag == "cameracollision"){
     transform.Translate(Vector3(0,0,0));
     shouldMove = false;
  }
}