Basically, I want my music player to play songs in order with a shortened amount of lines, but I don't know how to do it. I need some help, this is the code for my music player. It's working but not as I want it to be (I obviously know that there is nothing that attempts to do what I want it to do, but I find no solution in attempting to do it).
How do I do it?
local ContentProvider=Game:GetService('ContentProvider');
local ServerStorage=Game:GetService('ServerStorage');
local Song=ServerStorage:WaitForChild('Song');
local Playing=false;
local Songs={
438917260; --// 1
143959455; --// 2
243372213; --// 3
142295308; --// 4
401120618; --// 5
130844430; --// 6
130797915; --// 7
142435409; --// 8
143204341; --// 9
131111368; --// 10
572476178; --// 11
221681020; --// 12
606541503; --// 13
577407393; --// 14
131154740; --// 15
};
local Track=1;
function PreLoadAssets(Assets)
for _, ID in pairs(Assets) do
ContentProvider:Preload('rbxassetid://' .. ID)
end;
end;
PreLoadAssets(Songs);
function StartSong()
Spawn(function()
repeat Wait(0);
for _, V in pairs(Songs) do
if not Playing then
Playing=true;
Song.SoundId = 'rbxassetid://' .. V
Track=V;
print(_, V, 'eyyoo');
Song:Play()
break;
end;
end;
until Song.IsPlaying==false;
Playing=false;
print('Done');
Track=Track+1;
print(Track);
StartSong();
end);
end;
StartSong();

5 comments
oml...
What do you mean by "playing after one another?" How is it not working as you intended to? Your question is vague; could you please expand & be more specific on what you're asking/ talking about?
http://wiki.roblox.com/index.php?title=Writing_Clean_Code#Indenting
i didn't realize i didn't say anything about it rofl, changing
You can loop through the list and connect the Ended event to a function that starts playing the next song.