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

Music On/Off on clicked?

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

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)

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)

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)

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