Song playlist not working as intended

So, yesterday I tried to make a radio that plays music in a playlist that loops. (Inspired by the music cube from eqiunos ok place - Roblox)
I only have two songs in the rotation, as I just wanted to test it out before adding every song.
But it definitely didn’t work out as expected.
Instead of making a loop of songs from start to finish, it played a bit of the first song, then played the second half of the second song, then completely stopped. There were no errors in the output so I’m asking for help here.
Please tell me what I’m doing wrong and how I can actually make it work.

--variables
local Source = game.Workspace.Source


function music(SoundId)
	Source.Sound.SoundId = "rbxassetid://"..SoundId
    Source.Sound:Play()
    Source.Sound.Ended:Wait(0.1)
end

while true do 
    wait(0.2)
    music("466445479")
    music("5434920494")
    end

Help would be greatly appreciated. Thanks!
(Sorry if the script is messy)

2 Likes

You need a sound id and use the sound:Play() feature.

Make sure you create sound and put ID song in the sound.

A server one. A local wouldn’t really be a radio

Your using a string, Instead use numbers.

None of these have seemed to work, I’ll keep on trying but I’m not getting very far.

local ids = {0000, 0000} -- your song ids here
repeat wait()
    for i = 1, #ids do -- loops through the table
        local songObj = Instance.new("Sound")
        songObj.Parent = game:GetService("SoundService")
        local nowPlaying = ids[i]
        songObj.SoundId = "rbxassetid://"..nowPlaying
        songObj:Play()
        songObj.Ended:Wait()
        songObj:Destroy()
     end
until false

@jamies_coolio

4 Likes

Thanks! That worked almost perfectly, the only part was that instead of playing from the radio part, it played throughout the server, but that’s easy to change. I really appreciate it man!

1 Like