# Mini Menu Problems - Too Many Menus Spawning

**URL:** https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846
**Category:** Help
**Tags:** extension, game
**Created:** [January 12, 2024, 11:17pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846 "2024-01-12T23:17:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Blobbey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blobbey/32/20831_2.png) [@Blobbey](https://forum.makecode.com/u/Blobbey)
#### Post date: [January 12, 2024, 11:17pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846/1 "2024-01-12T23:17:15Z")

</div>

I know it would be more helpful if I posted the link to the game, but I don’t want to reveal the game yet. It seems as though there are too many menus spawning when the player presses ‘B’, which in turn causes a bunch of other problems. I’ve tried to set variables to keep the code from getting repeated,  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/982e6313cafd4748209cab218b76f4a2018e6e4d.png)  
but it isn’t working. Again, I know it’s harder to help when there’s no game link, but I don’t want to reveal my game yet. ☹

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [January 12, 2024, 11:31pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846/2 "2024-01-12T23:31:31Z")

</div>

Try using a different function for each menu change it won’t fix the issue, but it might make it easier to understand the problem when things are laid out nicely instead of one big line

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [January 12, 2024, 11:32pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846/3 "2024-01-12T23:32:39Z")

</div>

@Blobbey maybe you could share a screenshot of the relevant code but draw over it to redact the secret bits?

---

<div class="post-metadata">

### Author: ![Blobbey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blobbey/32/20831_2.png) [@Blobbey](https://forum.makecode.com/u/Blobbey)
#### Post date: [January 17, 2024, 6:27pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846/4 "2024-01-17T18:27:26Z")

</div>

Okay, here’s the first bit.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3abdc1e98f2e6930d986f10fd13de8a3815ca15c.png)  
Then, further down.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1cda8cd16d43a3e39aaa9387a9298fa9e44e5263.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0565a115605f74d299bfe825eafe566401b5ff57.png)  
These are the parts of the code that the problem seems to be coming from. I’ve been using the console log to pinpoint bugs, and it seems that several parts of the code (menu and morph fruit subtraction) seem to be getting repeated more than they should. I hope this helps.

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [January 17, 2024, 8:13pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846/5 "2024-01-17T20:13:35Z")

</div>

ah, thanks! that’s perfect.

the tile overlaps event that you’re using will fire for every frame that the sprite is overlapping with the tile. if you happen to hold the B button down for more than 1 frame, it’s going to end up spawning multiple menus. even worse, if the sprite is overlapping with multiple of those tiles (e.g. you covered an area with the tile) then it will potentially fire multiple times a frame and create even more menus!

luckily, it’s an easy fix. just create a variable named something like “isMenuOpen” and set it to true when you create the menu and false when the menu is closed. then you can check it inside of the overlap event and not open the menu if it’s still true. here’s a sample:

> **[menu-tile-overlaps-demo](https://arcade.makecode.com/S81913-66248-18663-49621)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![Blobbey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blobbey/32/20831_2.png) [@Blobbey](https://forum.makecode.com/u/Blobbey)
#### Post date: [January 17, 2024, 9:58pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846/6 "2024-01-17T21:58:15Z")

</div>

I thought that this code was supposed to take care of that. 😕  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/2c18b797ddf3d34164cf5cd9fd9f25cd2aa571ed.png)

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [January 17, 2024, 10:03pm UTC](https://forum.makecode.com/t/mini-menu-problems-too-many-menus-spawning/25846/7 "2024-01-17T22:03:43Z")

</div>

hmmm… where do you set morph to true?
