So I was recently commissioned to code a donation sign thing where you can add a gamepass, T-shirt, Shirts or Pants. So I was thinking about using the marketplaceservice function of :GetProductInfo but I am really confused about how to work this. I believe it requires whatever the ID is in a code thing but I am not sure how I can check to see what ID it links to.
Anyone got any ideas?
What I was sent by the user who asked me to create the sign as an example:
Like I said I attempted to use this market place service function but really does not work out for me.
I thought the “AssetTypeId” that we get when using this would give an ID for a game pass but after trying this with different game passes I got 2-3 different IDs. Got any idea why?
local marketplace = game:GetService("MarketplaceService")
local success, result = pcall(function()
return marketplace:GetProductInfo(129459077)
end)
if success then
if result then
if result.AssetTypeId == 2 then
print("T-Shirt!")
elseif result.AssetTypeId == 11 then
print("Shirt!")
elseif result.AssetTypeId == 12 then
print("Pants!")
end
end
else
warn(result)
end
To clarify, “Pants!” was printed in the above example.
What do you need their asset IDs for? You already know that they’re gamepasses.
local marketplace = game:GetService("MarketplaceService")
local success, result = pcall(function()
return marketplace:GetProductInfo(6240746, Enum.InfoType.GamePass)
end)
if success then
if result then
--Do code.
end
else
warn(result)
end
If you want to use GetProductInfo() to fetch information about them then you need to pass an optional “InfoType” Enum argument to it.
Only legacy gamepasses use the old asset ID system, newer gamepasses use the current gamepass ID system instead.
The person that hired me to do this wants them to be able to add either a T-shirt, Shirt, Pants or GamePass as I showed on the image above so it will not know what it is so I need to check to see what the ID they put in is.