Mute button sounds on all scenes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Movit

My game has 2 scenes (Main and Title).
Sounds (and Music) added via AudioStreamPlayer.
I need to create a button, when you click on which all sounds (and music) will be muted, and if you click on it again, it will be played further. How can i do this?

:bust_in_silhouette: Reply From: spaceyjase
var bus_idx = AudioServer.get_bus_index("Master")
AudioServer.set_bus_mute(bus_idx, true) # or false

Ty, but
With this function I can only turn off the sound, but how can I turn it back on?

func _on_Volume_pressed():
var bus_idx = AudioServer.get_bus_index("Master")
AudioServer.set_bus_mute(bus_idx, true)

Movit | 2021-11-29 15:55

You change the true to false.

spaceyjase | 2021-11-29 16:32

Can you write code please, just i’m so stupid ;3

Movit | 2021-11-29 17:10

For me it’s working thanks.

Ytachi1000 | 2022-11-06 11:44