I got an issue with my script. The script is able to play the song but doesnt display the name of the song. I cant figure it out.
Script:
local song = script.Parent.Song
local ids = {“4805888546”, “2692805133”, “1604537374”}
local marketplaceService = game:GetService(“MarketplaceService”)
while true do
for count = 1, #ids do
song.SoundId = “rbxassetid://”…ids[count]
songInfo = marketplaceService:GetProductInfo(ids[count])
song.Loaded:Wait()
song.TimePosition = 0
song:Play()
script.Parent.TextLabel.Text = "Now playing: "…songInfo.Name
song.Ended:Wait()
script.Parent.TextLabel.Text = “Loading next song…”
end
end
And for some reason devforum doesnt space out the script lol
You concatonated using .:. But you only need to periods so you want . sorry I’m on mobile so I can’t rewrite the code but does that make sense? It’s not letting me do 2 periods, sorry I have never posted in mobile before
I went ahead and revised your code for you. It works in the way you should expect with the same layout in the image you provided.
local songids = {
4805888546,
2692805133,
1604537374
}
--
local marketplaceservice = game:GetService("MarketplaceService")
--
local song = script.Parent.Song
local songinfo = nil
--
while wait() do
for i = 1,#songids do
--
song.SoundId = "rbxassetid://" .. songids[i]
songinfo = marketplaceservice:GetProductInfo(songids[i])
song.Loaded:Wait()
--
song:Play()
script.Parent.TextLabel.Text = "Now playing: " .. songinfo.Name
--
song.Stopped:Wait()
script.Parent.TextLabel.Text = "Loading next song..."
wait(math.random(2,3))
--
end
end