'Godot change_scene keep running last scene

I'm a newbie, and I'm working on a game using Godot.

I'm making a game called "Pong", I'm creating a winning scene when one player reaches 5 points.

Here is my code:

if self.score1 >= winning_score or self.score2 >= winning_score:    
        get_tree().change_scene("res://compWin.tscn")

The code works in changing scene but after the scene is changed, the last scene which is the game still keep running. How can I fix it?



Solution 1:[1]

I am unable to recreate this bug using your code, everything goes smoothly and the scene before compWin never ran in the background like you described. This error could be caused by other code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ClassicMushroom