Condition that no longer activates after a reset

Good morning, everyone,

Here I am currently in internship and I have to realize a small project a small prototype exactly this one is soon finished I only have small details to realize and I have to succeed before November 25.

So these are my problems, I make a platform game where
the objective is to touch a flag to reach the level ( as in super Mario Bros) to reach it the character must move from platform to platform by creating a bridge that allows him to reach the platforms one after the other to avoid falling, this bridge is made thanks to the Scale of a sprite on the Y axis which undergoes a rotation in order to cross however the scale must not be too big because otherwise we lose a point of life and the bridge this reset to a given position but the concern is that when I fall the reset is executed and I can again do my Scale on the Y axis + rotation so that’s good but on the other hand when I do a Scale too big the reset is done but I can no longer do my Scale on the Y axis and the same when I arrive on a new platform the reset is done but not the Scale on the Y axis.

Oh yes and for the moment I only test 2 platforms to know how to go about it afterwards.

Here is my code (be careful it’s not very beautiful but it’s my first time with javaScript and Phaser 3 so I’m not looking to make a game that works in a 1st temp and if I have the time to tickle it to make it cleaner):

function HealthPoints()
{

//displays the health points

info.setText( healthPoints);

//reset character and the bridge after the fall and lose of HP
if (character.y < wall.y + wall.height && character.y + character.height > wall.y
&& healthPoints !==0)
{
healthPoints–;
bridge.rotated = false;
character.body.pos.x = 38;
character.body.pos.y = 505;
bridge.syncGameObject()/.setDisplaySize(1,10)/.setBodyScale(1);
bridge.body.pos.x = 95;
bridge.body.pos.y = 528;
bodyBlock.body.pos.x = 91;
bodyBlock.body.pos.y = 520;
}

//condition for wins the health points
if (character.x < life.x + life.width + 33 && character.x + character.width - 33 
    > life.x && healthPoints !==3 ) 
{
    healthPoints++;
    //tripleFace.anims.play('espace');
    //Once time the sprite enter in collision this one is deleted of the memory
    life.destroy();
   
}

//Condition of defeat
if (healthPoints === 0) 
{
    text.setText('YOU\nLOSE'); 
    text.setPosition(text.width-20,text.height+150 );
    tripleFace.anims.play('left');
    character.setVelocity(0); 
    character.anims.play('stop');
   // this.input.on('pointerdwon',()=> this.scene.start('preolad'));
}

}

function update()
{

if (character.y > 505)
{        
     character.setGravity(50,50)       
}
velocity();

//Condition allowing the scale of the fine sprite and preventing it from 
//continuing the scale after the rotation
if ( keyboard.up.isDown && !bridge.rotated ) 
{ 
 bridge.scaleX = 1;    
 bridge.scaleY += (-0.30);
 bridge.syncGameObject()/*.setBodyScale(-this.bridge.scaleX/1,this.bridge.scaleY*1)*/;
 
}

// Rotation of the scale

if ( keyboard.down.isDown && !bridge.rotated )
{
bridge.rotated = true;
// Apply a collision to the sprite that was enlarged
bridge.syncGameObject().
setBodyScale(-bridge.scaleY * 10,bridge.scaleX / 10);
bodyBlock.body.pos.x = 70;
bodyBlock.body.pos.y = 540;
//bridge.setActive(false);
// defined the distance at not exceed between the platforms
if ( bridge.scaleX > distance + 10 )
{
healthPoints–;
//bridge.rotated = false;
bridge.syncGameObject().setBodyScale(1);
// bridge.syncGameObject().setDisplaySize(1,10).setBodyScale(1);
bridge.body.pos.x = 95;
bridge.body.pos.y = 528;
bodyBlock.body.pos.x = 91;
bodyBlock.body.pos.y = 520;
}
}

if (character.body.pos.x >= 451  ) 
{
  
    bridge.syncGameObject().setBodyScale(1);
    bridge.body.pos.x = 512;
    bridge.body.pos.y = 528;
    bodyBlock.body.pos.x = 91;
    bodyBlock.body.pos.y = 520;
    
}else if(character.body.pos.x >= 223  )
{

    bridge.syncGameObject().setBodyScale(1);
   
   bridge.rotated = false;
    bridge.body.pos.x = 287;
    bridge.body.pos.y = 528;
    //bridge.setActive(true);
    bodyBlock.body.pos.x = 284;
    bodyBlock.body.pos.y = 520;
    
}