Mute/unmute radio button help

I have a radio gamepass in my game where it is added onto a player’s back and they can play any audio they want. I would like other players to be able to mute/unmute the radio if someone is playing annoying, loud, or bypassed audios. If that player owns a radio themselves, they should still be able to hear their audio playing but mute everyone else’s radios after clicking the button. My guess would be to create a table with all of the player’s user IDs that own the gamepass and mute all of those audios, but I don’t have a strong understanding of using and referring to tables, let alone I don’t know if this would be the best method.

The way the radio works is by welding the radio onto the player’s character’s back, and when they enter the sound ID and click play it adds an audio into the radio mesh with that sound ID and when they click stop it gets deleted. So I would need to either work around this or just have the audio permanently be under the radio mesh, just with 0 as the ID when they click stop, which I think is the better method. Also, how would I work around someone with a radio joining and playing an audio? I would somehow need to update it.

TL;DR
In short, how can I make a table where I gather all of the players owning a specific gamepass and then locate sound IDs within their character’s to set the volume to 0 locally? And what happens if someone joins and starts playing a new audio?
Thanks!

4 Likes

You could create a simple ui where it would have a list of all the players with that certain gamepass, and a mute radio button next to it. Once clicked the mute radio button, a local script would disable the radio just for you since its a localscript. I would write some code examples but I’m on mobile right now.

1 Like

Or a button that mutes the radio totally, just like Breaking Point does.(Breaking Point is a roblox game.)

1 Like

What do you mean when you say “mutes the radio totally”?

I think this is a pretty good idea, but you’re going to have to show me how to do it, because I have no idea how lol. It would also be nice if I could have the player’s profile picture next to their name.

Well for the profile picture

     ''''
               local Players = game:GetService("Players")

               local player = Players.LocalPlayer

               local userId = player.UserId
               local thumbType = Enum.ThumbnailType.HeadShot
               local thumbSize = Enum.ThumbnailSize.Size420x420
               local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)

               local imageLabel = script.Parent
               imageLabel.Image = content
               imageLabel.Size = UDim2.new(0, 420, 0, 420)

           '''
2 Likes

Okay! Tommorow I’ll make the core of it and you can do around it and make it look how you want it to look. DM me tommorow lexi#8784!

1 Like

Editing the radio to add the sound to a SoundGroup when the sound is created, and turning the volume of the SoundGroup to 0 on the client seems like a reasonable solution.

I have finished doing a quick headstart for you which you can get here: start off for mute player gui.rbxm (8.4 KB)

It’s not fully scripted but it shows you what you need to do. Good luck!

Everything you need to accomplish this, will be linked below.

LocalScript: Here
Roblox API: Here

just wondering, how do SoundGroups work? If I want the sound to be emitting from the radio, how would i do that but also have it be apart of the soundgroup?

" A SoundGroup is used to manage the volume and effects on multiple Sound s at once. Every sound in the sound group will have its volume adjusted by the group’s SoundGroup.Volume property"

Parenting the sound to the handle of the radio like normally, but setting the SoundGroup property of the sound to the SoundGroup of all the radios, will allow the SoundGroup to control the Volume of all sounds that are in the SoundGroup. This makes it much easier to accomplish what you are trying to do.

Since I have nothing better to do, I’ll write a little tutorial on how to do this on the Golden Super Fly Boombox

First, create a SoundGroup under SoundService name it, “Radios” and set the Volume property to 1

Next, in the server script of the radio, you’re going to want to edit the function that creates the sound, so playSong()

Now you’re going to want to set the SoundGroup property to the SoundGroup we just created, so after the line

Sound = Instance.new’Sound’

put

Sound.SoundGroup = game:GetService(“SoundService”):FindFirstChild(“Radios”)

Now you’re done with editing the Radios script, all you need now is a way to change the volume on the SoundGroup. I made a simple LocalScript parented to StarterPlayerScripts that mutes/unmutes the SoundGroup when the player says /mute or /unmute

game.Players.LocalPlayer.Chatted:Connect(function(msg)
	if msg:lower() == "/mute" then
		game:GetService("SoundService"):FindFirstChild("Radios").Volume = 0
	elseif msg:lower() == "/unmute" then
		game:GetService("SoundService"):FindFirstChild("Radios").Volume = 1
	end
end)

I hope this helps anyone who had questions about this, and taught you a little bit about SoundGroups

15 Likes