How to save and load toggle button potation?

I created a toggle button to set the volume to 0 and to 100 for the background sound in Gdevolop. There I want the changes I made earlier on the toggle button to be displayed the same when I close and reopen the game. How to do it?

Hi akila. Here are some events, they assume you want your project to mute the music when the project starts, if the player had chosen to mute it last time they were using your project.

So some notes, you do not need Trigger Once in the same condition as Beginning of Scene. Beginning of scene is a special Trigger Once condition that is only run once, at the beginning of the scene.

Your Boolean True and Boolean False conditions are independant, stand alone event blocks. They do not need to be a sub-event that only happens after a mouse release on ToggleButton. If they are a sub-event to a mouse release on ToggleButton, then if you load a game where you saved information that a player has the music muted, the music will still play because those actions to mute the music will not be called unless the player performs the mouse release event again.

You need to both save and load the value of your global variable. When you load it you need to load it into a fake scene variable and then from there use it to change your real global variable.

Since this is a boolean you can choose to save it as a number (value) variable. When you write the action to load it into your global variable, you can also use a number variable (“Change number variable”). This is because if you try to “Change the boolean value” it will only offer you to set it as True or False with no way to use an expression, and of course you don’t know what the value was saved as. However since your real variable is a boolean this will not matter. (For me anyway though I did not test it with predeclared Name/Type variables.)

Actually I like this one better, it’s the same thing I just changed when to save so I, the user, am not bothered with having to click a button to confirm my changes.

1 Like

Wow… it worked. You helped me a lot…** Thank you so much Lucky-j…** :yellow_heart: :smiling_face:

1 Like