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

Why gui button cant stop/destroy or pause audio?

Asked by 4 years ago

So I am trying to make that when the player clicks on "PLAY" Button then destroy/stop audio but it isn't working. Here is the script.

game.StarterGui.Menu.PLAY.MouseButton1Click:connect(function()
    workspace.Sound:Destroy()
end)

2 answers

Log in to vote
0
Answered by 4 years ago

Here's a Script I made just now, it should hopefully work, ( Has not been tested tho )

It must be a local script in the button that it will pause it on.

local music = game.Workspace.Music -- Name the sound "Music"

script.Parent.MouseButton1Click:Connect(function()

if music.Volume == 0 then

 music.Volume = 1

 else

  music.Volume = 0

end
end)
0
What this does, is if the music volume is at 0. then it will turn it to 1.. else so basicly if it is on 1 it will turn it to 0. Piloten2008YT1 34 — 4y
0
Thank you very much! MatoProF 23 — 4y
Ad
Log in to vote
0
Answered by
jgftr7 74
4 years ago

So The Problem Is That You Don't Destroy The Music You Stop It. Try This:

game.StarterGui.Menu.PLAY.MouseButton1Click:connect(function()
    workspace.Sound:Stop()
end)

And If You Want to Play It Once Again Do this

game.StarterGui.Menu.PLAY.MouseButton1Click:connect(function()
    workspace.Sound:Play()
end)

Answer this question