Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I've Been Having Issues Making a Working Music Playlist?

Asked by 4 years ago

So recently I've decided to make a new showcase and wanted to try my hand at making an ambient music player, one that is stuck to a Part and the farther away you go, the quieter it becomes, which is simple enough in it's own right as it's built in. My problem is with actually Scripting a working playlist that goes through a list of 4 songs and starts back over at the beginning. Every single time I've tried a new script it'll just loop the first song, or play all four at the same time without fail. I'm pretty bad when it comes to Lua so any help is appreciated This is the script I tried using:

local sound1 = 131072261 local sound2 = 130872377 local music = script.Parent

while true do wait() music.SoundId = "rbxassetid://"..sound1 music:Play() music.Ended: wait() music.SoundId = "rbxassetid://"..sound2 music:Play() music.SoundId = "rbxassetid://"..sound3 music:Play() music.Ended: wait() music.SoundId = "rbxassetid://"..sound4 music:Play() music.Ended: wait() end

1
try music:Stop() after its done playing? Spiritlotus 151 — 4y
0
There's not sound3 and sound 4 PepeElToro41 132 — 4y
0
This script worked perfectly for me only if I delete the sound3 and sound4 lines PepeElToro41 132 — 4y
1
I've done this before. I can help you later if you want. ShashMouthDZX 15 — 4y

1 answer

Log in to vote
0
Answered by
Psudar 882 Moderation Voter
4 years ago
Edited 4 years ago

I've actually done this before, hopefully I can show you something cool and maybe you'll learn something from it :D !

--Server script
local soundObject = Instance.new("Sound") --im just creating this so you can easily copy-paste and mess around
soundObject.Volume = 1
soundObject.Parent = workspace

--creating a table of songs, i believe this is an array. 
local songTable = {
    [1] = "rbxassetid://1771529564";
    [2] = "rbxassetid://1836914205";
    [3] = "rbxassetid://1572323159";
    [4] = "rbxassetid://2087798404";
}

local function repeatTable()
    for i, v in pairs (songTable) do --loop through the array
        soundObject.SoundId = v --value of iteration 
        soundObject:Play() --play sound
        soundObject.Ended:Wait() --wait till the song is over to continue 
    end
end


while true do
    repeatTable()
    wait()
end

Hope this helped m8.

P.S Listen to the dope beats I put in the table

Ad

Answer this question