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

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

Asked by 4 years ago

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)
0
did ya figure it out? SamZeKat 28 — 3y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago

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)

0
Both functions would be called from the same event. Rinpix 639 — 4y

Answer this question