How can I make a “mute boombox” button?

I am trying to make a mute boombox button but it didn’t work. Here is the script.

local mousebutton1click = Boombox.Mute()

if mousebutton1click = false do

game.Boombox.Stop()

if Mousebutton1click = true do

game.Boombox.Play()

I do not know what is going on, the thing isn’t working. Ive seen many mute boombox buttons in other games but I do not know how to make one. Please help me because I do not want players playing awfully loud audio in my game.

5 Likes

it is not Boombox.Play() or Boombox.Stop() but instead of the full stop there is a colon:

game.Boombox:Play()
1 Like

I don’t think there is a service named Boombox…?

You’d have to manage it with your boombox that you have made, and as stated above, there’s no service named “BoomBox” by default.

I do not know how to make a mute boombox button. I did try using the normal word “boombox” but that didn’t work. I need a mute boombox button because I know that people will dislike my game because players would play loud, bypassed audio. I know there is a mute boombox button in name snipes generator and a boombox test game but I do not know how I can make one.

Can you show me all the properties of the boombox you made?

Is boombox a sound or something? Because as many others said, there’s no service called “boombox”.

Also, you can’t do if mousebutton1click = true, you have to do

   Button.MouseButton1Click:Connect(function()
         —code here
   end)

I do not know how I can make the mute boombox button. I really am new to sound services. My game would be ruined if I do not have a mute boombox option. This is getting very struggling. I do not want people sending me messages on who is playing loud audio and ban them from the game. If I basically ban them from the game, they just wasted robux. I really need the button because I do not want my inbox to be filled with people reporting users usernames to ban them from my game.

This code is very vague so there’s not much we can do. Also, game.Boombox makes so sense whatsoever, Boombox isn’t a service or anything like that.

How you would do this is to reference all of the boomboxes somewhere and keep track of them in something like a table. After, make a SoundGroup and put it somewhere like in SoundService. Then, for the sound that each boombox plays (I’m assuming each boombox just has a sound in it and the player inserts an id), make sure it’s always connected to the SoundGroup.

After that, all you’d have to do is change the volume of the SoundGroup. When the mute is enabled, change the SoundGroup’s volume to 0 on the client (because only they should have it muted). When it isn’t, change it back to its original volume.

Also, if you don’t know what a SoundGroup is, to put it simple, it’s basically an object that allows you to control multiple sounds at once once they’re connected to the SoundGroup.

What I would do is check out where the boombox puts the sounds when their playing, then once the button is clicked, I would search for those sounds then set the volume to 0.

for example if the boombox puts the sound in the characters head, and names it boombox then I would do a loop searching for all the players then doing a if statement to see if they have the sound then mute all those sounds!

Example

for i,v in pairs(game.Players:GetPlayers()) do
	local s = v.Character.Head:FindFirstChildOfClass("Sound")--// Or if it names it you can use FindFirstChild()
	if s then
		s.Volume = 0
	end
end

Hope this helps!

EDIT:

I got bored and made a little file which contains the default boombox tools and I used the example above this message to make it work. Here ya go!
BoomboxExample.rbxl (25.3 KB)

Please note I didn’t scale the UI or anything so don’t like expect it to work ingame.

:slight_smile:

1 Like

The first thing I will say is that this code won’t work because its not proper syntax. When you’re programming, don’t just make up stuff on the way if you don’t know how to do it properly. I’m assuming you’re pretty new at programming, so here are some of the major things I want to point out so I can help you learn.

  • mousebutton1click’s value is taking Boombox.Mute(), which means that its a function and also taking a variable/instance that has not been established beforehand. (That, or this is just some random snippet of code, which even then I doubt that .Mute() is a function that exists)
  • The conditional statement is basically checking if mousebutton1click’s value is false, therefore meaning its a boolean. However, you aren’t using == to check if mousebutton1click’s value is false. == and = are used differently, as == is used for checking a variable’s value and = is used to set it.
  • If the conditions are met, it would get a service called Boombox and use .Stop. However, Boombox is not an actual service.
  • You forgot to put an end at the end of the conditional statement. This also applies to the other conditional statement.

However, these are all relatively simple fixes. I’m assuming that this is just a LocalScript under a TextButton, so the first thing we’ll do is set up two things: A variable for the button, and also an event.

The event will activated whenever the button is clicked.

local Button = script.Parent

Button.MouseButton1Click:Connect(function()
    
end)

Now we’ll need to utilize SoundService. The first thing we’ll do is basically set up is inserting a SoundGroup into SoundService. We’ll name it “Boombox Music”.

If you have a Boombox tool, just get the script that is handling the sounds and basically use this script (make sure to change the Sound of Sound.SoundGroup to the Sound Instance that the Boombox is using. If you need help on this, tell me.)

Sound.SoundGroup = game:GetService("SoundService"):WaitForChild("Boombox Music")

Now, we’ll go start programming how we actually handle muting sound. We’ll start by creating a boolean variable called MusicDebounce. We’ll make its value true.

Afterwards, we’ll go create a conditional statement within the MouseButton1Click function that basically will check MusicDebounce’s value.

local Button = script.Parent
local MusicDebounce = true

Button.MouseButton1Click:Connect(function()
    if MusicDebounce  == true then
        
    else

    end
end)

Looking good so far. Now, we’ll be making it so that it will mute the Boombox Music SoundGroup along with changing MusicDebounce’s value. We’ll start by creating a variable for the Boombox Music instance and then afterwards changing its volume.

local Button = script.Parent
local MusicDebounce = true

local BoomboxMusicGroup = game:GetService("SoundService"):WaitForChild("Boombox Music")

Button.MouseButton1Click:Connect(function()
    if MusicDebounce  == true then
        MusicDebounce = false
        BoomboxMusicGroup.Volume = 0
    else
        MusicDebounce = true
        BoomboxMusicGroup.Volume = .5
    end
end)

And there you have it, a fully functional Boombox Muting script.

9 Likes