Help getting gamepass ids

Hello fellow developers,

So i have a module script for getting all items in the players inventory for a ‘pls donate’ type game.

All items copy on the frame everything works EXCEPT the fact that when i click on the button to purchase it i get this error:

this is my module script:

local AssetManager = {}

local HttpService = game:GetService("HttpService")
local UrlA = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorName="

local function getUserGeneratedTShirtsRecursive(username, SignPrices, tshirts, cursor)
	tshirts = tshirts or {}
	local requestUrl = UrlA
	local data = HttpService:JSONDecode(HttpService:GetAsync(UrlA .. username)).data
	if data then
		table.sort(data,
			function(a,b)
				return a.price < b.price
			end
		)
		for _, item in ipairs(data) do
			local e,s = pcall(function()
				table.insert(tshirts, item.id)
				local newBtn = script.Template:Clone()
				local price = item.price
				newBtn.PurchaseButton.price.Text = "$"..price
				newBtn.LayoutOrder = price
				newBtn.Name = price
				newBtn.ImportantValues.AssetId.Value = item.id
				newBtn.Parent = SignPrices

			end)
		end
	end
	return tshirts
end

local UrlB = "https://www.roproxy.com/users/inventory/list-json?assetTypeId=34&cursor=&itemsPerPage=100&pageNumber=%s&userId=%s"

local function getUserCreatedGamepassesRecursive(userId, SignPrices, gamepasses, pageNumber, lastLength)
	gamepasses = {}
	pageNumber = pageNumber or 1
	lastLength = lastLength or math.huge

	local requestUrl = UrlB:format(pageNumber, userId)
	local success, result = pcall(function()
		return HttpService:GetAsync(requestUrl)
	end)

	if success then
		if result then
			local success2, result2 = pcall(function()
				return HttpService:JSONDecode(result)
			end)

			if success2 then
				if result2 then
					for _, gamepass in ipairs(result2.Data.Items) do
						if gamepass.Creator.Id == userId and table.find(gamepasses, gamepass.Item.AssetId) == nil then
							table.insert(gamepasses, gamepass.Item.AssetId)
							local e,s = pcall(function()

								local newBtn = script.Template:Clone()
								local price = gamepass.Product.PriceInRobux
								newBtn.Name = price
								newBtn.PurchaseButton.price.Text = "$"..price
								newBtn.LayoutOrder = price
								newBtn.ImportantValues.AssetId.Value = gamepass.Item.AssetId
								newBtn.ImportantValues.AssetType.Value = "Gamepass"
								newBtn.Parent = SignPrices
							end)
						end
					end
				else
					warn(result)
					getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
				end
			end
		else
			warn(result)
			getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
		end
		return gamepasses
	end
end


function AssetManager:GetAssets(Player, BoothUI)
	getUserGeneratedTShirtsRecursive(Player.Name, BoothUI)
	getUserCreatedGamepassesRecursive(Player.UserId, BoothUI)
end

return AssetManager

this is my button handler script:

local MarketplaceService = game:GetService("MarketplaceService")

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local playerGui = player.PlayerGui
local donationUI = playerGui:WaitForChild("donationUI")

local mainFrame = donationUI:WaitForChild("mainFrame")
local buttonsHolder = mainFrame:WaitForChild("buttonsHolder")

for _, Desc in pairs(buttonsHolder:GetDescendants()) do
	if Desc:IsA("TextButton") and Desc.Parent:FindFirstChild("ImportantValues") then
		Desc.MouseButton1Click:Connect(function()
			if Desc.Parent.ImportantValues.AssetType.Value == "Clothing" then			
				MarketplaceService:PromptPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
			elseif Desc.Parent.ImportantValues.AssetType.Value == "Gamepass" then
				MarketplaceService:PromptGamePassPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
			end	
		end)
	end
end

buttonsHolder.DescendantAdded:Connect(function(Desc)
	task.wait()
	if Desc:IsA("TextButton") and Desc.Parent:FindFirstChild("ImportantValues") then
		Desc.MouseButton1Click:Connect(function()
			if Desc.Parent.ImportantValues.AssetType.Value == "Clothing" then			
				MarketplaceService:PromptPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
			elseif Desc.Parent.ImportantValues.AssetType.Value == "Gamepass" then
				MarketplaceService:PromptGamePassPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
			end	
		end)
	end
end)
1 Like

Do you have 3rd party purchases turned on?

is this a group game? try turning on 3rd party purchases in the games settings

is the issue still happening when u try

yea i still get the error popup but no errors in the output

I think i found the issue it gets the wrong id how do i get it to get the right id?

idk im not experienced with modules

make a new post on this bcuz this got old if no one responds soon

I fixed it already thanks for your help tho

umm ok ig idk how i helped but ill take it

You still gave info TRYING to help

ok um anyways gl on ur game looks cool

1 Like