Input key not working when going from a widget to another

Hello! I am setting up the main menu for my project, which has four buttons, two of which remove the main menu widget and create either the settings menu widget or the credits widget.

I’ve set an input key to go back or close widgets, which works okay until I do the following:

  1. Open one of the two widgets, close it
  2. Open the second one, close it
  3. Open the first one again.

After doing that the input doesn’t work and it won’t do anything. I know the input key is the issue (or at least I’m 99% sure it is) because I tried just printing a string and it doesn’t.

I’ve revised the code a thousand times, and I still don’t know why this happens. It doesn’t happen when I open and close just one of them, even if I do it multiple times.
Here’s the code to open and close both widgets:

Show settings widget:

Hide settings widget:

Show credits widget:

Hide credits widget:

Calling the settings widget from the main menu widget:

Calling the credits widget from the main menu:

Input key to go back from the settings widget:

Input key to go back from the credits widget: