Do You Check if a Product is a Gamepass or a Devproduct, what I mean is something a check along the lines of ,
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(product, Enum.InfoType.Asset)
end)
if success then
print(productInfo.ProductType)
if productInfo.ProductType == "GamePass" then
Could you explain why this script cannot recognize the ProductID.
local MainFrame = script.Parent
local GamepassesFrame = MainFrame:WaitForChild("Gamepasses")
local DevProductsFrame = MainFrame:WaitForChild("DevProducts")
local MPS = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
local CollectionService = game:GetService("CollectionService")
local allButtons = CollectionService:GetTagged("RobuxPurchaseButton")
local function BuyProduct(product)
local success, productInfo = pcall(function()
return MPS:GetProductInfo(product, Enum.InfoType.GamePass)
end)
if success and productInfo then
print("Gamepass ID:", productInfo.ProductId)
print("Gamepass Name:", productInfo.Name)
print("Gamepass Description:", productInfo.Description)
else
print("Gamepass Error:", productInfo)
success, productInfo = pcall(function()
return MPS:GetProductInfo(product, Enum.InfoType.Product)
end)
if success and productInfo then
print("Developer Product ID:", productInfo.ProductId)
print("Developer Product Name:", productInfo.Name)
print("Developer Product Description:", productInfo.Description)
else
print("Developer Product Error:", productInfo)
print("Invalid product ID")
end
end
end
for _, button in pairs(allButtons) do
button.MouseButton1Click:Connect(function()
local productID = button:FindFirstChild("ID")
if productID and productID:IsA("StringValue") then
BuyProduct(productID.Value)
else
print("Invalid product ID")
end
end)
end