Say if I wanted to retrieve all possible audio id's using a ridiculously long for loop, and used the GetProductInfo of the MarketplaceService.
wait() for idAsset = 156000000, 131000000, -1 do -- Rough approx. of newest sound id to oldest sound id. local curId = game:GetService("MarketplaceService"):GetProductInfo(idAsset) if curId then -- This id exists. print(curId.Name) -- Print the name of the sound. end end
However, when it executes for the first time:
MarketplaceService:getProductInfo() failed because rawProductInfo was empty.
I can't check whether it is nil (or otherwise empty)?
It'd be significantly faster to parse them out of the catalog. There are only ~34,000 audio.
Start with PageNumber=1 and work your way up.
wait() for idAsset = 156000000, 131000000, -1 do -- Rough approx. of newest sound id to oldest sound id. local s, curId = pcall(function() return game:GetService("MarketplaceService"):GetProductInfo(idAsset) end) if s and curId then -- This id exists. print(curId.Name) -- Print the name of the sound. end end
This should work. GetProductInfo errors if there is no asset with that ID. I would suggest adding waits if you experience latency.
The method :GetProductInfo() returns a dictionary table that you can search through. It will not give you the results you're looking for if you just check to see if it exists or not. You should be able to check to see if certain things in this library are nil if it would not exist, such as when it was created or it's creator.
Try using this:
wait() for idAsset = 156000000, 131000000, -1 do -- Rough approx. of newest sound id to oldest sound id. local curId = game:GetService("MarketplaceService"):GetProductInfo(idAsset) if curId.Created ~= "null" then -- This id exists. print(curId.Name) -- Print the name of the sound. end end