MarketplaceService:GetProductInfo() failing

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:
image
I even tried wrapping it in a pcall() but yet nothing.
How can I get the song name as a workaround?

This was posted 2 YEARS ago yet nothing changed:

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.

Might be because 2 IDs are being pulled, 1 could be a gamepass, the other an asset, and it can’t pick and choose which to display.

What’s the 0 for? As far as I know, :GetProductInfo returns a Dictionary.

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

songinfolabel.Text = "Now playing: " … v.Name

Something like that.

Ok I will try that and get back to you ASAP.

You got it my guy. Best of luck.

1 Like

This isn’t working because you are calling :GetProductInfo() on your song variable, not sounds[song].

2 Likes

AHHHHH the realization got me. Good catch. Totally blew over me lol.