Stop Movement & loop

Hi,

I am working on a small puzzle game and I am quite new to programming, I wanted to have an object which moves continuesly up and down.
So I created an object added a script with the following information:

var objectSpeed: int;

function Update () {

amtToMove = objectSpeed * Time.deltaTime;

transform.Translate(Vector3.down * amtToMove);

if(transform.position.y <= -3.4){
transform.Translate(Vector3.up * amtToMove);

}
}

What happens now is that the object is moving down till it reaches -3.4 and then stopps, i guess this happens because it moves up and down at the same time. So my question is how do I stop the down movement and get it to move upwards and then down again and so on ?

Thanks in advance

The problem is that when it only attempts to move upwards if it is below its lowest point! This means that after it has moved up, it will immediately start moving down again.

You should manage this with a boolean that switches between upward and downward motion.

var movingUp : boolean = false;
var topHeight : float = 0;
var bottomHeight : float = -3.4;

function Update()
{
    if(movingUp)
    {
        transform.Translate(objectSpeed * Time.deltaTime * Vector3.up);
        if(transform.position.y >= topHeight)
        {
            movingUp = false;
        }
    } else {
        transform.Translate(objectSpeed * Time.deltaTime * Vector3.down);
        if(transform.position.y <= bottomHeight)
        {
            movingUp = true;
        }
    }
}