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

Playing a song right after a song ends..?

I've tried this multiple times but I never got any facts on how to do it :

Say you have a table of ids:

sounds = {id,id,id}

-- If I wanted to make it so it picks a random id using:

math.random

-- How would I make it so once a song ends one plays?
-- Is TimeLength working yet, meaning wait(name.TimeLength)?

1 answer

✓ Accepted answer
local ContentProvider = game:GetService("ContentProvider")

Ids={IdNumber, IdNumber, IdNumber}

for i,v in pairs(ids) do
	ContentProvider:Preload("rbxassetid://" .. v) --Always good to preload songs and such so they are ready when you need them.
end



while wait(1) do

	song=Songs[math.random(#Songs)]
	SoundInstance.SoundId="rbxassetid://"..song --SoundInstance is the sound object you are using to play the song. 

	wait(1) --Give it a little time just in case
	song=SoundInstance
	song:Playe()
	wait(song.TimeLength)
	song:Stop() 
	wait(1) --just to make sure it has stopped before loading another song.
end

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