How do I make a button that mutes all boomboxes except for the local player?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to create a button that will mute all player’s boomboxes (EXCEPT for the local player’s boombox).

  2. What is the issue? Include screenshots / videos if possible!
    I am having a lot of trouble creating the code for it. I’m not really sure what I’m doing wrong and also not sure what else I could try for it to work.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried researching on the dev forum and everything I found is either not really what I’m looking for, it’s not working for me, or I’m just not understanding it at all.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Hello! I’m sorry if I did anything wrong as this is my first ever post on the Dev forum. I basically want to create a button that will mute everyone’s boombox EXCEPT for the local player’s boombox(aka the person who pressed the button). I don’t need any help with creating the GUI for the button. However, I’m having a lot of trouble with creating the code itself.

Here is the code that is inside a local script:

local button = script.Parent

local muted = false

local players = game:GetService(“Player”)

button.MouseButton1Click:Connect(function()

for _, player in pairs(players:GetPlayers()) do
	local Boombox = player.Backpack:FindFirstChild("Boombox")
	
	if player ~=  players.LocalPlayer then
		local BoomboxVolume = Boombox.Handle.Sound.Volume
		
		if Boombox and muted == false then
				muted = true
				player.Boombox.BoomboxVolume = 0
				print("Boombox is muted")
		end
	end
end

end)

I’m a beginner scripter so I’m really sorry if my script is terrible. I honestly have no idea where to go from here. Any help is MUCH appreciated!!

In your script you are just muting the boombox for other players on your computer which does not affect other players.
You need to fire a remote event to the server and the server will be able to mute the other sound-boxes except for the player who from whom the re was fired.
for example -
–local script

local re = game.ReplicatedStorage:WaitForChild("RemoteEvent")  
--Just fire the remote event when you want. 

--server script
local re = game.ReplicatedStorage:WaitForChild("RemoteEvent")  
re.OnServerEvent:Connect(function(p) -- "p" the player who fired the remote event. 
    for _ , v in pairs(game.Players:GetPlayers()) do
        if not(v == p) then
            if (p:FindFirstChild("Backpack") then
                -- find the box and mute from there
            end 
        end 
    end           
end

Edit: If you want to mute the other boxes just for yourself there will no need to get into so much trouble.
In that case your code seems fine I suppose.