How Do You Check if a Product is a Gamepass or a Devproduct

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
3 Likes

It returns an AssetTypeId. You can check for that value with an Enum.

1 Like

Could you elaborate? I think you are referring to the Enum.InfoType.Asset, am I wrong?

This Enum can be used to match the AssetTypeId from MarketplaceService:GetProductInfo() to an asset type.

Quote from documentation.

My problem is that I have a variable product which is a gamepass id, but it doesn’t pass the if productInfo.ProductType == "GamePass" then

Quick skim through the docs, don’t think ProductType is actually a property of productInfo. You’re probably comparing “GamePass” to nil.

You should be using AssetTypeId, then look through the documentation that @SomeFedoraGuy sent you to work out which ID you want to compare it to.

local assetTypeId = productInfo.AssetTypeId
	print(assetTypeId)
	local assetType = Enum.AssetType:GetEnumItems()[assetTypeId]

the assettype for some reason is 1 which is an image even tho the product variable is a gamepass

You’ll need to double check that the ID is correct then

The product / the assetid of the gamepass is correct

1 Like

According to the second parameter you put, you need to re-visit the InfoType enum.

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

Nvm I had an old string value check

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.