Layer not becoming hidden when touched outside of an object

I’m making a menu with a simple box that pops up when I click on the texts and disappear when I click outside of the box.
The box should appear when I click the select level button and disappear if I press outside of it.
It does pop up when I click it and the buttons inside it work but when I click outside of it nothing happens. The box doesn’t disappear and I’m not sure why.

Box on the right with the buttons for level 1 to 3 should pop up and disappear.

Here is the code for it:

Basic visual functions and layer showing when clicked on the text.

Code that should hide the layer with the box.

Are you trying to hide “Levels” or “Settings”? There’s a show “Levels” but hide “Settings”

Wait damn it I think I screenshotted the wrong code part. But both settings and levels use same code.

I meant to screenshot this but I was too tired to notice I guess

Now if I click the text object the layer doesn’t even appear. I didn’t change the code so now I’m really not sure what’s causing the issue.