Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I turn off all sounds that exist in a game?

I need someone to possibly make a script where it just makes all sounds in the game have a false playing property.

Here is what I made but it doesn't turn off any sound whatsoever. Can someone help me to make it turn off every sound that is in the game at all?

model = game local children = model:GetChildren()

for i = 1, #children do
	local child = children[i]

	if child:IsA("Sound") then
		child.Handle.Sound.Playing = false
	end
	end

2 answers

local descendants = game.Workspace:GetDescendants()
for i,v in pairs(descendants) do
      if v:IsA("Sound") then
            V.Playing = false
      end
end

Note: sorry if its not formated cause I am on phone and its impossible to format it

2 comments

0

I think you could just do game:GetDescendants() instead of just searching the workspace.

0

if you do that you will get some security errors.

To stop playing a sound, you should use sound:Stop() or sound:Pause(). The latter will remember position and can be resumed. Now if all your sounds are in the workspace, then all you need is to use workspace:GetDescendants(). This will search ALL the elements, not just children, but childrens children and so forth.

local descendants = workspace:GetDescendants()
for i = 1, #descendants do

	if descendatnts[i]:IsA("Sound") then
		descendatnts[i]:Stop() --or Pause()
	end

end

Now this method is not very efficient, so if you plan to stop all sounds a lot, then consider a sound table, where you add all sounds and then just iterate through that table. Also this script will not stop any sounds played locally (like player gui).

Have a nice scripting session.

This discussion is preserved as it was. New answers, comments, and votes are closed.