Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I create a script that sets music's volume to 0 when I press a Gui?

Okay so I have a script that stops the music when I press a gui (Stop music button) but I would like to just set the volume to 0 instead of stopping it. Could anyone help it? This is the script I'm using

stopped = false
sound = game.Workspace.Sound
script.Parent.Text = "Music: ON"
script.Parent.MouseButton1Down:connect(function()
    if stopped == true then
        sound:Play()
        stopped = false
        script.Parent.Text = "Music: ON"
    else
        sound:Pause()
        stopped = true
        script.Parent.Text = "Music: OFF"
    end
end)

1 answer

✓ Accepted answer

this should work

local stopped = false
local sound = game.Workspace.Sound -- i just put local cuz im used to makeing local variables
script.Parent.Text = "Music: ON"
script.Parent.MouseButton1Down:connect(function()
    if stopped == true then
        sound.Volume = .5 -- grab the volume property and set to .5 or however high you want it
        stopped = false
        script.Parent.Text = "Music: ON"
    else
        sound.Volume = 0 -- grab the volume property and set to 0
        stopped = true
        script.Parent.Text = "Music: OFF"
    end
end)

5 comments

0

shouldn't it be sound.Volume = 0.5?

0

Also give me your discord so I can give you some robux through a group

0

he wanted 0 not .5 :S

0

i think .5 or 0.5 would work honestly i would use 0.5 to be safe and steve its set to .5 when the sound is playing -- my disc is Donut792#1329

0

Added you

This discussion is preserved as it was. New answers, comments, and votes are closed.