Need help in Pause-Resume game

Hello I’m new to Phaser but going pretty great for now. I’m having problems in the pause menu, whenever I click on my pause button the screen pauses but when I want to resume the game the gamescene restarts instead of continuing. Please help me I have a deadline for my project

Show your code please.

This is code for my pause screen

class Pause extends Phaser.Scene {

constructor() {

    super('pause')

}

preload() {

    //preloading all the stuff

    // this.load.image('background', 'assets/unnamed.png')
}

create() {

    //background for the Main Menu

    // this.add.image(110, 110, 'background')

    //Main Menu text

    this.add.text(110, 50, "Pause Menu")

    this.resumeButton = this.add.text(100, 100, 'Resume game', { fill: '#fff' })

        .setInteractive({ useHandCursor: true })

        .on('pointerover', () => this.enterButtonHoverState2())

        .on('pointerdown', () => this.enterButtonActiveState2())

        .on('pointerup', () => {

            this.enterButtonHoverState2();

        });

}

enterButtonHoverState2() {

    this.resumeButton.setStyle({ fill: '#000' });

}

enterButtonRestState2() {

    this.resumeButton.setStyle({ fill: '#fff' });

}

enterButtonActiveState2() {

    this.scene.switch("GameScene")

    this.scene.switch("UIScene")

}

}

And how does it pause the game, before that?

I have a button in another scene that fires the pause screen
Here is the code for that

this.pauseButton = this.add.text(350, 1, ‘Pause’, { fill: ‘#fff’ })

        .setInteractive({ useHandCursor: true }).on('pointerover', () => this.enterButtonHoverState1())

        .on('pointerout', () => this.enterButtonRestState1()).on('pointerdown', () => this.enterButtonActiveState1())

        .on('pointerup', () => {

            this.enterButtonHoverState1();

        });

}

enterButtonHoverState1() {

    this.pauseButton.setStyle({ fill: '#000' });

}

enterButtonRestState1() {

    this.pauseButton.setStyle({ fill: '#fff' });

}

enterButtonActiveState1() {

    this.scene.start("pause")

    let gs = this.scene.get("GameScene")

    gs.scene.pause()

}

Do you want GameScene and UIScene visible or invisible while paused?

Invisible, and when I resume the game I want it to be visible

OK, it should be

class UIScene {
  // […]
  enterButtonActiveState1 () {
    this.scene.launch('pause');
    this.scene.sleep('GameScene');
    this.scene.sleep();
  }
}

Oh my God!! It worked. Thank you so much :heart::heart::heart: