I should've known that the for loop was the problem, oh well...
instead of using for loops you what you could do is:
local array = {foo,bar}
local pos = 0
local function foo()
pos = pos + 1
if pos >= #array then pos = 0 end
-- do stuff here
end
————
Hello, I've been having problems with a music playlist script, while it does mostly work, the only problem is that it automatically skips to the end of the list.
Script:
local MarketplaceService = game:GetService("MarketplaceService")
local MusicList = require(game:GetService("ReplicatedStorage").Modules.Databases.Music)
local CurrentSong = script.Parent.CurrentSong
local MusicTitle = script.Parent.MusicTitle
local function nextSong()
for _,id in pairs(MusicList) do
CurrentSong.SoundId = "rbxassetid://"..id
CurrentSong:Play()
MusicTitle.Text = MarketplaceService:GetProductInfo(id).Name
end
end
nextSong()
CurrentSong.Ended:Connect(nextSong)
If a demonstration is required please visit this link.

1 comment
you are looping through the entire table thats why