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

How to make a clickable screen gui that would mute/unmute music?

So i want to do a code that when its left clicked it would mute the music and when right clicked it would unmute music, and the button would be a GUI screen button.

function leftClick()
	game.SoundService.vibing.Playing = false
 
function rightClick()
	game.SoundService.vibing.Playing = true
end
 
script.Parent.MouseButton1Click:Connect(leftClick)
script.Parent.MouseButton2Click:Connect(rightClick)

1 comment

0

did ya figure it out?

2 answers

You aren't really muting it though you are just trying to stop it on left click and play it on right click but doing it the wrong way. Also your functions need to be local.

local function leftClick()
    game.SoundService.vibing.Volume = 0 -- Mutes the Volume
end

local function rightClick()
    game.SoundService.vibing.Volume = 0.5 -- Mess with the number if you want
end

script.Parent.MouseButton1Click:Connect(leftClick)
script.Parent.MouseButton2Click:Connect(rightClick)

What this script is it actually mutes the volume instead of stopping or playing it.

You need to use .activated not .Mouseclicked

function leftClick()
    game.SoundService.vibing.Playing = false

function rightClick()
    game.SoundService.vibing.Playing = true
end

script.Parent.Activated:Connect(leftClick)
script.Parent.Activated:Connect(rightClick)

(idk if this is right but its usually what i do)

1 comment

0

Both functions would be called from the same event.

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