Hey! I am currently a new scripter and I have watched quite a few tutorials on how to create my own Music System. I kept it so something basic, as I did not want a Mute button or a Skipping System. Due to a few Youtube tutorials not helping at all, I decided to use the Devforum for some help and support.
It has came to my attention that when I tried testing the game, the first song played perfectly, then the next few ones did not at all. I changed the script a couple of times, but nothing worked, so I decided to delete a few songs from the actual playlist and came to the conclusion that I have only 4 left.
How do I make it so every single song plays instantly after the previous one has successfully ended?
Do they need to loop? I’d use the following script:
while true do
script.Parent.Calming:Play()
script.Parent.Calming.Ended:Wait()
script.Parent.Temporex:Play()
script.Parent.Temporex.Ended:Wait()
script.Parent.Chetta:Play()
script.Parent.Chetta.Ended:Wait()
script.Parent.Lovely:Play()
script.Parent.Lovely.Ended:Wait()
end
the sounds and script are both parented to the same object, it should work if it’s in a service where server scripts are able to run
Would be even better to just use a single audio object and have the script update the asset Id instead of playing each individual audio one after the other.
Instead of using wait, I’d recommend waiting until the Ended event of the Sound object is fired, and then connecting with a a Wait().
But wait. What happens after the last song is played? It’ll stop.
This is why we need to put it in a loop. So that it can repeat indefinitely.
while true do
game.Workspace.Calming:Play()
game.Workspace.Calming.Ended:Wait()
game.Workspace.Temporex:Play()
game.Workspace.Temporex.Ended:Wait()
game.Workspace.Chetta:Play()
game.Workspace.Chetta.Ended:Wait()
game.Workspace.Lovely:Play()
game.Workspace.Lovely.Ended:Wait()
end