The problem with closing the pause menu on the same button that it opens

Hello. Tell me, please, what is the problem? How to implement, in my case, closing the pause menu by pressing the same button that opens it?

The problem was solved by this construction.