# Script continuing even though the player has won

**URL:** <https://forum.makecode.com/t/script-continuing-even-though-the-player-has-won/8606>\
**Category:** Help\
**Created:** [June 8, 2021, 2:22pm UTC](https://forum.makecode.com/t/script-continuing-even-though-the-player-has-won/8606 "2021-06-08T14:22:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Coolboy300](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/coolboy300/32/4371_2.png) [@Coolboy300](https://forum.makecode.com/u/Coolboy300)\
**Post date:** [June 8, 2021, 2:22pm UTC](https://forum.makecode.com/t/script-continuing-even-though-the-player-has-won/8606/1 "2021-06-08T14:22:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [June 8, 2021, 3:30pm UTC](https://forum.makecode.com/t/script-continuing-even-though-the-player-has-won/8606/2 "2021-06-08T15:30:30Z")

</div>

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.
