How can I get a pass or product from an ID?

Lets say someone buys a dev product or a game pass, I want to be able to get the item they bought using the ID. Any way to do this?

1 Like

No I want to use a script to get a pass. I know how to find them

MarketplaceService | Documentation - Roblox Creator Hub
see if this helps
at GetProductInfo

oh so you want to check if a player owns or bought a gamepass?

1 Like

I tried this, every time I put in my ID it gives me a whole different product. Im not sure why though

I want to be able to get the things info that they bought yes

This might help just replace “YOUR_PRODUCT_ID_HERE” with your product ID.

local ProductId = "YOUR_PRODUCT_ID_HERE"  -- Replace with the Product ID of your Dev Product or Game Pass

game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
    local playerId = receiptInfo.PlayerId
    local productId = receiptInfo.ProductId

    -- Check if the received product matches the one you want to grant
    if productId == ProductId then
        -- Grant the item to the player (e.g., give them a tool, change a value, etc.)
        -- Replace this with your own logic for item granting.
        -- For example, you can use ServerStorage to store items and clone them to the player's Backpack.
        local item = game.ServerStorage:FindFirstChild("YourItemName"):Clone()
        item.Parent = game.Players[playerId].Backpack
    end

    return Enum.ProductPurchaseDecision.PurchaseGranted
end

Did you use Enum.InfoType.GamePass as the second argument? It’ll return only assets by default if you don’t specify what category the ID belongs to. InfoType.Product exists for developer products too.

I meant more of getting the data of the item/product the bought. Sorry for not explaining very well

1 Like

Great this works perfectly! Once a user buys something though, how do I tell if they bought a product or a gamepass? Like when I process a receipt

You can fetch all developer products from MarketplaceService and loop through the list to find an ID that matches the receipt. If it isn’t in there, it’s a game pass and not a product. The list of developer products also has the description information so you don’t have to use GetProductInfo on products unless you always want up-to-date information.

I was going to say pcall UserOwnsGamePassAsync but you can’t be sure your developer product doesn’t share an ID with a gamepass that player also owns.

2 Likes

I tried this

Bad news it only lets you get certain products I believe, and not all of them. Is there another way?

It returns a Pages instance, which you need to advance yourself after storing the current page. I edited an example from the API reference to make this:

local developerProducts = {}
do
	local productPages = MarketplaceService:GetDeveloperProductsAsync()
	while true do
		table.insert(developerProducts, productPages:GetCurrentPage())
		if productPages.IsFinished then
			break
		end
		productPages:AdvanceToNextPageAsync()
	end
end
-- do stuff with developerProducts

ProcessReceipt only exists for developer products because they’re non-permanent and repeatable. If you want to hook onto any gamepass purchases, PromptGamePassPurchaseFinished can do that.

1 Like