Yep! You can do that with an Audio element + listeners/actions.
-
Play the custom music: Add an Audio element to a universal layout (so it can run on every screen you care about) and configure it with your track(s) like described on the Menu Background Music page. Use a Music Controller element there too if you want to mute the vanilla menu/world music.
-
Trigger the music randomly: Create an “On Screen Opened” listener (see the Listeners doc). In its action script, use the
{"placeholder":"random_number","values":{"min":"1","max":"100"}}placeholder inside anIFblock (you can nest it in a Calculator if needed) to check whether the random roll hits your desired chance. When it does, run aSet Volume/audio_toggle_playaction (see the Action Scripts list) to start the Audio element. -
Stop the music when closing: Add an “On Screen Closed” listener, and run
audio_toggle_play(or set the element’s volume to 0) for the same Audio element so it pauses/stops as soon as the menu closes.
That setup gives you a chance to play the special track each time a screen opens, while ensuring it’s muted again when the menu is left. 😊