Delay on a function that triggers when the settings menu is closed

Basically, I’m making a game with custom game settings which you can open by pressing CTRL+S, and I made a simple UI that shows up when the player presses “Esc” that reminds them of the CTRL+S menu.

This is my script:

And this is a video of the problem:

As you can see, when I close the menu by hitting Esc again, the UI stays on the screen until the settings UI is completely gone and THEN tweens out.

Is there a fix for this? If so, can someone tell me how to fix it? Thanks.

Maybe try making it tween faster

I tried that already, it’s not because of the tween; it waits until the main settings menu is out of the way and then starts the tween

I’m guessing the MenuClosed function of GuiService only fires when the menu is fully closed, instead, you could use UserInputService and tween the frame whenever the ESC button is pressed.