[solved! thank youu] Mute and Unmute button for my background music doesn't works

Hello, my question is I want to have a mute and unmute button for the background music of the game. I set a global variable named “Music” I set it as Boolean and True

  1. The music can be played but it takes a while for the music to start. I wish the music starts playing as the scenes pop up (it could be an internet problem or something else but do tell me hehe)

  2. It seems that I need to click multiple times on the MusicButton so the music will be muted. I did notice that when I hold the left click longer the button gitters/flickers between MusicButtonNormal, MusicBUttonHover, and MuteButton.


WhatsApp Image 2024-01-10 at 3.06.24 PM

  1. When I manage to mute the music, the button doesn’t stay at the MuteButton animation. I have to looooong press the button for it to appear but then again the gitter/flicker between three animations (MusicButtonNormal, MusicBUttonHover, and MuteButton.) happens.

I hope someone can help me <3

Hi @Mobii,

1- Because of the limitations of browsers, sounds will never play until the user interacts with the game for the first time. It’s a bummer but you’ll have to find a workaround and make the player interact with the game after the scene loads before playing the sounds.

2- Since you’re trying to have a hovering effect I believe you should have 2 hovering animations for the button, 1 when normal and 1 when muted (if this is what you’re going for). Also there are some issues with how you built your events that are causing the problems.

Try this instead (attached screenshot)

1 Like
  1. Owhh I see :astonished :astonished: Thankk Youuu @mikeshouman !

  2. I was trying to do the hovering animation and It makes sense that I need 2 hovering animations! Mind asking how would it look like for the Mute_Hover to be included?

I’m going to run this code first to get a sense of the event, I really need to check how I build my events sob sob.

Update!

I tried it and the music button works! but sadly the music is so slow. I need to find a workaround fr

For the animations, just create the same hover effect for both normal and mute animations and give them the same name but add something like “Hover” at the end.

In my example I named them:

  • Normal
  • Normal_Hover
  • Mute
  • Mute_Hover

recording

As for the music, did you mean that it takes time to start playing? If so, then maybe you need to check the “preload as sound” checkbox in the resources. Also the file size shouldn’t be too big.

Hope this helps.

The music works ! The music finally playss


Thank youuu so much !! :sparkles: :tada:

1 Like

Cool ! I’m glad I was able to help

1 Like