Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there any script that mutes all sound in the game?

Asked by 6 years ago

I want to have button which mutes all sound in the game.

0
In Workspace? Or the entire game Wafflecow321 457 — 6y
0
Entire Game User#15070 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You should design a game using SoundGroups as it will allow you to mute the groups you want ie music, sfx and other channels.

It is best to handle the sound correctly when it is added into your game by setting a sound group for it.

You can do this with a script but you would not know the original volume of the sound as you cannot simply stop all music due to a lot of scripts needing to play sound is the character died.

A basic approach would be to get a list of all sound instances and set the volutme to 0 then connect an event to set all new sound instances volume to 0 as well

for _, itm in pairs(game:GetDescendants()) -- i am unsure the locations of where sound can be played so I will simple mute all sounds. 
-- you can do your own testing to find where sounds play

    if itm:IsA('Sound') then
        itm.Volume = 0
    end 
end

-- mute all other sound added to the game
game.DescendantAdded:Connect(function(ins)
    if ins:IsA('Sound') then
        ins.Volume  = 0
    end
end)

I hope this helps. You will need to look at which method is best for you.

Ad

Answer this question