Is there a way to have an audio playlist without having to script one?

Hi I am just wondering if there is a way to have an audio playlist without having to script one because I have like 20 songs that I want to use but It will take a long time to get the ids and type them in manually into the script.

1 Like

No there is not. You can easily achieve this though by putting all the songs you want in a folder and then looping through that folder and play each song then wait till it ends, then the next song will play etc

1 Like

do I have to put the script in the folder how would i do that

1 Like

Have the script outside of the folder, it can reference the folder and get all the songs inside of it then use a loop and play them. You can add a script by right clicking an instance in workspace and clicking add object then select script.

1 Like

so have the script be the parent of the folder

1 Like

You could do it that way yeah.

1 Like

how would i start it im not really a scripter i mostly build

1 Like

You could just do this by putting all of the audio-ids into a table and then use a for-loop to go through all of them:

Ids = {
    ID,
    ID,
    ID,
}

This creates a table with all of your audio ids. Now to play all of them you could use a for loop:

for i, v in pairs(Ids) do

end

Now to play all of the ids you should do something like this (In the for-loop)

game.Workspace.Audio.SoundId = v --Sets the ID to the current one
game.Workspace.Audio:Play() --Plays it

Now to detect when the audio stopped to see when the next song should play you could use something this:

game.Workspace.Audio.Stopped:Wait()

If you put that in the loop it should wait until the current song stops until it plays the next one.

Hope this helps!

2 Likes

He said he wanted to avoid writing every Id, that’s why I said just to fill a folder with every sound instance.

Oh my bad, I misunderstood the topic.

Might just replace the IDs = {} with a GetChildren(), it returns a table as well. Also I’d use the for i, v in pairs do with a for i=1,#IDs do

will it play all of the audios without me having to put the ids in manully

Basically you only need a folder with Sounds. The script gets the children of sounds and puts it as a table, and plays them one by one for the entirety of the folder.

IDs = YourFolderLocation:GetChildren()

for i=1,#IDs do -- Goes through the Sounds one-by-one until the end
--Code
end
2 Likes

ok thank you30charrssssssssssssssss

1 Like

No problem! The code I posted is just a blank template though, you still need to add code inside the for loop to your liking. Here are some articles you might find helpful:

quick question i grouped all of the audios can i put the script in the model or does it need to be in a folder

Anywhere you like :slight_smile: As long as you can locate the YourFolderLocation it should still run.

Example: script.Folder (if the folder is inside the script), game.Workspace.Folder (if the folder is in workspace)

so it needs a folder inside of it

1 Like