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.