My question is the question here (i wrote it on my alt) I just posted here fore answers for it.
How to make a button that can mute boomboxes in a server?
2 answers
In the server script in your post, I don't recommend getting the children inside the player, and I also don't recommend using the legacy for i = 1, #childrensTable do since you can use for i, v in pairs(childrensTable) do but it still works. Instead, you look for every descendant in workspace and if it's a sound, you can mute it by setting the volume to 0.
local function muteBoom()
for _, descendant in pairs(workspace:GetDescendants()) do
if descendant:IsA("Sound") then
-- if (descendant.Parent.Name ~= "Handle") and (not descendant.Parent.Parent:IsA("Tool")) and (descendant.Parent.Parent.Name ~= "BoomBox") then return end -- only use this if you don't want to mute every sound in the game
descendant:SetAttribute("OriginalVolume", descendant.Volume) -- creates a backup
descendant.Volume = 0
descendant:GetPropertyChangedSignal("Volume"):Connect(function() -- when the volume changes
if descendant.Volume > 0 then -- making sure it isn't muted
descendant:SetAttribute("OriginalVolume", descendant.Volume)
end
end)
end
end
end
But the problem is that this is a VERY BAD practice since it can break the server and anyone can mute everyone's boom boxes, and you also want it to make it happen to the player who clicked (the client). So instead, let's move it to the client.
:bindEvent("selected", function(self)
print(("%s was selected!"):format(self.name))
iconz:setLabel("..Unmute Boomboxes..")
for _, descendant in pairs(workspace:GetDescendants()) do
if descendant:IsA("Sound") then
-- if (descendant.Parent.Name ~= "Handle") and (not descendant.Parent.Parent:IsA("Tool")) and (descendant.Parent.Parent.Name ~= "BoomBox") then return end -- only use this if you don't want to mute every sound in the game
descendant:SetAttribute("OriginalVolume", descendant.Volume) -- creates a backup
descendant.Volume = 0
descendant:GetPropertyChangedSignal("Volume"):Connect(function() -- when the volume changes
if descendant.Volume > 0 then -- making sure it isn't muted
descendant:SetAttribute("OriginalVolume", descendant.Volume)
end
end)
end
end
end)
:bindEvent("deselected", function(self)
print(("%s was deselected!"):format(self.name))
iconz:setLabel(" Mute Boomboxes ")
for _, descendant in pairs(workspace:GetDescendants()) do
if descendant:IsA("Sound") then
-- if (descendant.Parent.Name ~= "Handle") and (not descendant.Parent.Parent:IsA("Tool")) and (descendant.Parent.Parent.Name ~= "BoomBox") then return end -- only use this if you don't want to mute every sound in the game
local originalVolume = descendant:GetAttribute("OriginalVolume") -- gets the backup
descendant.Volume = originalVolume
end
end
end)
EDIT: Thanks for giving me the idea to use Player.Character instead. If you want to mute all boomboxes except for you, just go through all players, and if it's not the client (you) it will mute their boombox.
:bindEvent("selected", function(self)
print(("%s was selected!"):format(self.name))
iconz:setLabel("..Unmute Boomboxes..")
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if player ~= game:GetService("Players").LocalPlayer then
local character = player.Character or player.CharacterAdded:Wait()
local descendant = character:WaitForChild("BoomBox"):WaitForChild("Handle"):WaitForChild("Sound") or player:WaitForChild("BoomBox"):WaitForChild("Handle"):WaitForChild("Sound")
descendant:SetAttribute("OriginalVolume", descendant.Volume) -- creates a backup
descendant.Volume = 0
descendant:GetPropertyChangedSignal("Volume"):Connect(function() -- when the volume changes
if descendant.Volume > 0 then -- making sure it isn't muted
descendant:SetAttribute("OriginalVolume", descendant.Volume)
end
end)
end
end
end)
:bindEvent("deselected", function(self)
print(("%s was deselected!"):format(self.name))
iconz:setLabel("..Mute Boomboxes..")
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if player ~= game:GetService("Players").LocalPlayer then
local character = player.Character or player.CharacterAdded:Wait()
local descendant = character:WaitForChild("BoomBox"):WaitForChild("Handle"):WaitForChild("Sound") or player:WaitForChild("BoomBox"):WaitForChild("Handle"):WaitForChild("Sound")
local originalVolume = descendant:GetAttribute("OriginalVolume") -- gets the backup
descendant.Volume = originalVolume
end
end
end)
13 comments
the problem is that the sound isnt even in workspace its in the players backpack if they own a gamepass.
and i only want to mute boomboxes not all sounds i dont want my background sound gone i already have a separate button for that
First, the sound WILL be a descendant of workspace when you equip the boombox. Equipping any tool will be parented to the character, and the character is parented to the workspace.
And second, I already put a backup line in line 4 incase if you have a background music in workspace. Just remove the two dash lines at the very left of line 4.
And use the second script inside the Topbar script
Getting the boombox from the player’s backpack won’t work since the boombox ur currently hearing is parented in the workspace.
A sound will only play in workspace, not in the player’s backpack
Sorry if u think im mad, im not mad im just correcting you :)
My job is to help scripters
sure no problem thanks for helping
However I want the localplayer's boombox to still produce sound, only should every other player's boombox be muted
i would also recommend to not go through the whole workspace and use player.character since i have a lot of stuff in workspace and it would reduce performance
Thanks for giving me the idea to use character instead. I updated my answer and it should work now.
Hey there I have also found a sort-of solution: The problem is that it mutes ALL boomboxes even though i want the locaclplayer's boombox to produce sound
so the question is can i remove the localplayer from the table of players?
iconz
:setLabel(" Mute Boomboxes ")
:setName("boomxes")
:bindEvent("selected", function(self)
print(("%s was selected!"):format(self.name))
iconz:setLabel("..Unmute Boomboxes..")
bool = true
bool2 = false
while bool do
for i,v in pairs(players) do
print(v.DisplayName)
local backpack = v.Backpack
if backpack:FindFirstChild("BoomBox") ~= nil then
print("OK")
local boombox = backpack:FindFirstChild("BoomBox")
boombox.Handle.Sound.Volume = 0
elseif v.Character:FindFirstChild("BoomBox") ~= nil then
local boomboxc = v.Character:FindFirstChild("BoomBox")
boomboxc.Handle.Sound.Volume = 0
wait()
end
end
end
end)
:bindEvent("deselected", function(self)
print(("%s was deselected!"):format(self.name))
iconz:setLabel(" Mute Boomboxes ")
bool = false
bool2 = true
while bool2 do
for i,v in pairs(players) do
print(v.DisplayName)
local backpack = v.Backpack
if backpack:FindFirstChild("BoomBox") ~= nil then
print("OK")
local boombox = backpack:FindFirstChild("BoomBox")
boombox.Handle.Sound.Volume = 1
elseif v.Character:FindFirstChild("BoomBox") ~= nil then
local boomboxc = v.Character:FindFirstChild("BoomBox")
boomboxc.Handle.Sound.Volume = 1
wait()
end
end
end
end)
})
2 comments
and i know i have unnessessary line i will remove them later!
https://developer.roblox.com/en-us/api-reference/class/SoundGroup is your best bet
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Im not clicking links
ok
Hey! I saw your post again and someone already solved it. Uhmm, can you try my answer too? I tried my best to answer this question, and I’m super sure my answer works the way you wanted. Please don’t abandon my question, please try it, and tell which is better. If the other guy’s script better, then good for him and for you :)
don’t abandon my answer*
And don’t qorry I changed mg script to use player.Character like what you said to me