Enemy not moving forward and backward :(

I am making the enemy move around certain positions until i get him to attack but when i use the X,Y,Z values he only moves back and forth (Left & Right) But after going from left to right i want him to go forward back left then backward then right (Repeat) here is my code for forward backward,

         } 
    if (((current <= this.Z) && (this.Velocity < 0)) &&
       ((current >= this.Y) && (this.Velocity > 0))) {
        this.Velocity = -this.Velocity;
    } 
    //if (((current <= this.)))
    
    else  {
    if (((current <= this.Z) && (this.Velocity < 0)) ||
       ((current >= this.Y) && (this.Velocity > 0))) {
        this.Velocity = -this.Velocity;
    }
    }

But when i do this the enemy just vibrates in the same position and ive been brainstorming for a while now but cant figure this out any help would be nice :slight_smile:

Could we see some more of your script? Or maybe post a link to your project page.

https://playcanvas.com/editor/project/605986