stop and start an object going up

Hello, i have a question. my question is how to stop or start my cube going up by clicking the box collider? My cube is going up by this script

void Update()
{
transform.Translate(Vector3.up * Time.deltaTime, Space.World);
}

Hi, create a new bool called for example CanMove and then create the function OnMouseDown that detects if you click on the collider with the script attached.

    public bool CanMove;

    void Update()
    {
        if (CanMove == true)
        {
            transform.Translate(Vector3.up * Time.deltaTime, Space.World);
        }
    }

    void OnMouseDown()
    {
        CanMove = !CanMove;
    }