Script continuing even though the player has won

I’m making a maze game with music and at a certain point of the song, enemies appear.
The problem is if the player ends after the enemies disappeared then the song will continue and the enemies will appear again. I have two theories of how I could solve this but I’m not too sure how I’ll achieve it.

  1. Blacking out the screen and destroying the player:
    Could work but enemies and music would still show up I think.

  2. Force stopping the forever loop:
    I think this would be the best solution.

The easiest way would be to use a variable to say whether we are in a game or not. You should spawn the enemies only whether we are in a game and set it to false when the player loses.

1 Like