The .setVelocityY (or .setVelocityX) teleports the object a certain amount of pixels every frame

i am trying to get this wood to go up and down the screen but it only goes up… then keeps going up…

this is my code

class woodScene extends Phaser.Scene
{
    constructor()
    {
        super("woodScene");
    }

    preload()
    {
        this.load.image('wood', 'wood.png');
    }

    create()
    {
        this.upDownWood = this.physics.add.sprite(515, 325, 'wood');
        this.upDownWood.body.setImmovable(true);
        this.upDownWood.body.setAllowGravity(false);
        this.upDownWood.setVelocityY(-100);
   }

   update()
   {
        if (this.upDownWood.y == 580)
        {
            this.upDownWood.setVelocityY(-100);
        }  
        if (this.upDownWood.y == 0) 
        {
            this.upDownWood.setVelocityY(100);
        }
   }
}

it appears everything in the update function isnt working

I got it to work. the thing was that instead of doing if (this.blahblahblah.y == x) you should to this.blahblahblah.y > x or this.blah.y < x. this is because set velocity y just teleports the block up a few pixels every second. if you wait for the .y value to equal zero to do something and the .y is at three and it the .y value is subtracted by ten every frame the .y value will equal -7 next frame and it will never equal zero and you will never be able to do that thing you wanted to do when .y = 0. I hope you guys understand this.