This is a local script inside Gui. Every time id is a gamepass id it prints:
Invalid Asset Type. Expected a shirt, t-shirt, game pass, or pants but got 9
And does not work, but if it is a shirt, pants, t-shirt id no issue occur. How can I Make Gamepasses work?
local function validateProduct(id)
local success, info = pcall(function()
return MarketplaceService:GetProductInfo(tonumber(id))
end)
if success and info then
-- Debug print for AssetTypeId
print("AssetTypeId for ID", id, "is", info.AssetTypeId)
-- Check if the asset is a shirt, t-shirt, game pass, or pants
local validAssetTypes = {
[11] = "Shirt", -- AssetTypeId 11 for shirts
[12] = "Pants", -- AssetTypeId 12 for pants
[2] = "T-Shirt", -- AssetTypeId 2 for t-shirts
[34] = "Game Pass", -- AssetTypeId 34 for game passes
}
if validAssetTypes[info.AssetTypeId] then
if info.IsForSale and info.PriceInRobux and info.PriceInRobux >= 10 then
return true, validAssetTypes[info.AssetTypeId]
else
return false, "Item is not for sale or has an invalid price."
end
else
return false, "Invalid Asset Type. Expected a shirt, t-shirt, game pass, or pants but got " .. info.AssetTypeId
end
else
return false, "Failed to get product info. Error: " .. tostring(info)
end
end
I also added print statements to make sure id is the correct gamepass id