✓ Accepted answer
Simply put, no.
The loop doesn't wait for the song to end. Rather, it just continuously plays songs repeatedly, and seeing as how you have no waits in your script, it should actually crash the game via infinite loop (unless you have a wait at some other point in the "while loop").
First, we'll address the problem with the song.
I would suggest using a "repeat" to yield the loop. Here is an example of what I mean:
repeat wait() until Song.IsPlaying == false
This just loops over and over again until the song is done playing, then allows the code to pass this point. As an added bonus, you won't actually have to include any other waits than the one I included in this function (unless you choose to of course).
Here's what your entire while loop should look like with this added in:
while true do
Song = Instance.new("Sound")
Song.Parent = workspace
Song.Volume = 1
Song.Looped = false
Assets = {274504661,346191865,263966756,220964582,362105653}
for _, asset in pairs(Assets) do
game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
end
Song.SoundId = "http://www.roblox.com/asset/?id=" ..Assets[math.random(1, #Assets)]
Song:Play()
wait(Song.TimeLength)
end
Anyways, I hope this helped. If not, or if you have any further problems/questions, please leave a comment below, and I'll see what I can do.
1 comment
Sorry about not responding right away, I updated my answer, it might be a problem with the boolean not updating automatically? Anyhow, it should work now, I used one of the ideas Chemical posted in the comments. Be sure to give him an upvote if it works :P