I'm trying to make a music player but i cant detect if the sound stopped or ended, Although i did use the events Stopped and Ended but didnt work
Call me a bad scripter but i dont know if this is good enough for a music player.
local SoundIds = {
'http://www.roblox.com/asset/?id=359748862',
'http://www.roblox.com/asset/?id=319758951',
'http://www.roblox.com/asset/?id=130777688',
'http://www.roblox.com/asset/?id=243372213',
'http://www.roblox.com/asset/?id=340910520',
'http://www.roblox.com/asset/?id=228676342',
}
local Ended == false
while true do
if Ended == false then
local Music = Instance.new('Sound', game.Workspace)
Music.SoundId = SoundIds[math.random(1, #SoundIds)]
Music.Name = 'In-game_Music'
Music.Volume = 0
Music:Play()
for i = 0, 1, .1 do
Music.Volume = i
wait(.4)
end
Music.Stopped:connect(function()
Ended = true
for i = 1, 0, -.1 do
Music.Volume = i
wait()
end
repeat wait(.5) until Ended == true
if Ended == true then
wait(.5)
game:GetService('Debris'):AddItem(Music, 2)
end
end)
end
end

1 comment
Stopped and Ended functions only work with local scripts.