You can do this with a single Audio element plus a little action-script logic that remembers the state in a FancyMenu variable.
-
Add the music player
- Right‑click the editor background → New Element → Audio.
- Add your tracks and keep the element invisible (so it just plays in the background).
- If you need help with the general setup, see the menu music guide: Menu Background Music.
-
Create a variable for the toggle state
- Outside the editor, open Customization → Variables → Manage Variables and add a variable like
music_enabledand set it totrue. - You’ll use this to remember whether your music should be playing. Docs: Variables.
- Outside the editor, open Customization → Variables → Manage Variables and add a variable like
-
Make the toggle button
- Add a custom button, right‑click it and choose Edit Action Script.
- Build this script:
IF (Is Variable Value music_enabled == true, use the “OPPOSITE” option) Set Variable Value → music_enabled:false Set Audio Element Volume → your_audio_id:0 ELSE Set Variable Value → music_enabled:true Set Audio Element Volume → your_audio_id:1Set Audio Element Volumeis listed under Action Scripts and expectselement_identifier:volume. - This will mute your audio element when
music_enabledbecomesfalseand restore the volume when it becomestrue.
-
(Optional) Update the button label
- Set the label to something like
Music: {"placeholder":"getvariable","values":{"name":"music_enabled"}}so it showstrue/falseor wrap it inswitch_caseif you want “On/Off”. Placeholder info is in Placeholders.
- Set the label to something like
That’s it—each click flips the variable and instantly adjusts the volume. You can expand this by adding sounds, colors, etc., once you’re comfortable with action scripts and variables. 😊