Help With Music Playlist Script

For Awhile now i have been trying to get a music playlist script to work. And was wondering if any of you guys on devfourm would like to help. I posted the script down below can someone tell me what i can improve or a new script that works.

local sound1 = 2916513007

local sound2 = 4920228588

local sound3 = 4924408580

local sound4 = 3971705705

local sound5 = 5003002018

local sound6 = 4765665712

local sound7 = 3357632161

local sound8 = 4595551862

local sound9 = 4755430395

local sound10 = 4660430142

local sound11 = 5160602746

local sound12 = 4958498037

local sound13 = 3483276733

local sound14 = 741916467

local sound15 = 2493008044

local sound16 = 185993000

local sound17 = 201041079

local sound18 = 5065936056

local sound19 = 1438441315

local sound20 = 403883273

local sound21 = 5078905195

local sound22 = 1333217879

local sound23 = 3063172500

local sound24 = 2231029439

local sound25 = 2146629043

local music = script.Parent

while true do

wait(5)

music.SoundId = “rbxassetid://”…sound1

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound2

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound3

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound4

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound5

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound6

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound7

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound8

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound9

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound10

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound11

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound12

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound13

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound14

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound15

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound16

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound17

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound18

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound19

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound21

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound22

music:Play()

music.Ended:wait(5)

music.SoundId = “rbxassetid://”…sound23

music:Play()

music.Ended:wait(5)

end

1 Like

Don’t repeat functions like playing the music or changing the soundid, this can be done like so.

function NewSong()
music:Play()
music.Ended:wait(5)
end

You can repeat this over how many times by just typing NewSong()

I have made a music system in the past if you would like to check it out or take some parts from it, get it here: https://www.roblox.com/library/5171182863/ - Make sure to leave credit :slight_smile:

I hope this helps.

2 Likes

thanks it helped i will for sure check out you link

1 Like

If you put all the sound IDs in a table, then loop through the table, you can accomplish this same code in a matter of a couple lines:

local music = script.Parent
local soundIDs = {
    "2916513007";
    "4920228588";
    --repeat with all of your sound IDs
}

while true do
    for i = 1, #soundIDs do
        music.SoundId = "rbxassetid://"..soundIDs[i]
        music:Play()

        wait(music.TimeLength + 5) --for each sound, it'll wait its time length + 5
    end
end
6 Likes