Help: How to make a sound/music on/off button?

Does anyone know how to make a play/stop sound button? Like a button that can stop sound when you click, but if you click it another time the music starts up again

If you’re trying to mute/ unmute music, then this might be what you’re looking for:


To mute all sounds:

Howler.volume(0); /* sets volume to zero percent */

To unmute all sounds:

Howler.volume(1); /* sets volume to hundred percent */

To stop a specific sound from playing, then you’ll need to create a variable connected to the sound asset in a default script.

project.musicSound = this.project.getAssetByName("file.ogg");

^ replace “file.ogg” with the name of the asset

After creating the variable, this code should play the sound:

project. musicSound.play();

and this code should stop it:

project. musicSound.stop();
2 Likes

Ah, thanks I think this is the code was looking for! much appreciated :ok_hand: :sparkles: :heart:!

1 Like