Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Donut792 216 Moderation Voter
6 years ago
Edited 6 years ago

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)
0
shouldn't it be sound.Volume = 0.5? Chiprian1C 2 — 6y
0
Also give me your discord so I can give you some robux through a group Chiprian1C 2 — 6y
0
he wanted 0 not .5 :S 129Steve129 7 — 6y
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 Donut792 216 — 6y
0
Added you Chiprian1C 2 — 6y
Ad

Answer this question