[SOLVED] Pause and unpause with the same button

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

I want to pause a game by clicking with the left mouse button, then unpause it by clicking the left mouse button again.

What is the actual result

The game doesn’t pause at all.

Related screenshots

Project files (optional)

Insert a minimal game showing your issue in a .zip or .rar.

Hello, Sponge918

Gdevelop reads events from top to bottom. After reading all the events, it updates the game and this is considered a frame. In your game when the player clicks to pause, the game is paused and changes the “CanPause” variable to “false”. In the bottom event, the condition checks this variable again and because it was changed to false the actions occur and your game is not paused anymore. To avoid this you can use the “toggle” action for your boolean variable. Something like this:

1 Like

Thanks. I’ve figured this out.