I am trying to make a music system and this is what I got so far:
local ms = game:GetService("MarketplaceService")
local sound = script.Parent.Sound
local songinfolabel = script.Parent.Frame.TextLabel
local sounds = {
2183613911,
4556119843
}
for i = 1, #sounds do
local song = math.random(1, #sounds)
script.Parent.Sound.SoundId = "rbxassetid://" .. sounds[song]
sound.Loaded:Wait()
sound.TimePosition = 0
sound:Play()
local success, errormessage = pcall(function()
songinfo = ms:GetProductInfo(song)
end)
if success then
print("Got song name!")
elseif errormessage then
warn(errormessage)
end
songinfolabel.Text = "Now playing: " .. songinfo
sound.Ended:Wait(3)
songinfolabel.Text = "Loading next song..."
end
However, the script keeps failing because of this:
I even tried wrapping it in a pcall() but yet nothing.
How can I get the song name as a workaround?
GetProductInfo() has 2 parameters, 1 of which being the product, the other is the type. Maybe try doing ms:GetProductInfo(song, 0). If that doesn’t work, try using 1 instead of 0. I’ve never seen this error before.
Yes, I tried looking at the Developer Hub but that did not help as it says “ID does not exist” yet the song plays fine. The problem is that the request constantly fails.
Alright, if you wanted to do a backup system where it plays a table of songs. What I would do is create a folder in workspace, name it “Sounds” or something. Manually put in the Sounds, rename each sound to the name of the song. Use a for i,v in pairs(game.Workspace.Sounds:GetChildren()), and then say something like