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!
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.
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.
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.
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.
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