Inventory with game and ui mode (help)

Hey there, I could need some help with some inventory stuff.

I’m trying to lock the camera when the inventory open up. It works but when i’m trying to close the inventory it doesn’t work. Screenshot below / / /

Have a great day and thanks for helping.