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

Music On/Off on clicked?

Asked by
NotSoNorm 777 Moderation Voter
10 years ago

I don't know how to change it to where if you click on it again it will stop the music. Help D:

function Clicked()
game.Workspace.SurfacePart.Songs.Song1:Play()
end

script.Parent.MouseButton1Down:connect(Clicked)

4 answers

Log in to vote
1
Answered by
trogyssy 221 Moderation Voter
10 years ago

I hate that 1.5 minute cooldown -_-

local playing=false
function Clicked()
if not playing then
game.Workspace.SurfacePart.Songs.Song1:Play()
elseif playing then
game.Workspace.SurfacePart.Songs.Song1:Pause() --Change this to :Stop() if you want
end

script.Parent.MouseButton1Down:connect(Clicked)

Ad
Log in to vote
1
Answered by 9 years ago

!Imgur

Log in to vote
0
Answered by 10 years ago

Lol I really don't know how to make a short script on how to stop it but this is what I did and it stopped songs for me

PLAY

function Clicked()
local song = game.Workspace.MUSIC:Clone()
song.Parent = game.Workspace
song.Name = "CLONENAME"
game.Workspace.CLONENAME:Play()
end

script.Parent.MouseButton1Down:connect(Clicked)

END

function Clicked2()
game.Workspace.CLONENAME:Destroy()
end

script.Parent.MouseButton1Down:connect(Clicked2)
Log in to vote
0
Answered by 10 years ago

I think this'll work;

wait(0)
gui=script.Parent.Parent:FindFirstChild("Sound")
script.Parent.MouseButton1Down:connect(function()
if gui~=nil then
if gui.IsPlaying then
gui:Stop()
elseif not gui.IsPlaying then
gui:Play()
end end)

Answer this question