How would I find the game passes that a user has on sale

Hello, I’m trying to make a system that finds game passes that the user has on sale, I have the code that would find a user’s shirts, is there a way to make it find game passes?

local http = game:GetService("HttpService")
game.Players.PlayerAdded:Connect(function(plr)
	local baseUrl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=13&Limit=30&CreatorName=%s&cursor=%s"

	local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
	tshirts = tshirts or {}
	cursor = cursor or ""
	local requestUrl = baseUrl:format(username, cursor)
	local success, result = pcall(function()
		return http:GetAsync(requestUrl)
	end)

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

			if success2 then
				if result2 then
					for _, tshirt in ipairs(result2.data) do
						table.insert(tshirts, tshirt.id)
					end

					cursor = result2.nextPageCursor
					if cursor then
						return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
					else
						return tshirts
					end
				end
			else
				warn(result)
			end
		end
	else
		warn(result)
	end
end

local username = plr.Name
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --3
print(table.concat(userTShirts, " ")) 


for i, v in pairs(userTShirts) do
		local Template = script.Template:Clone()
		Template.Parent = game.Workspace.Map.Booths:WaitForChild(plr.UserId):WaitForChild("DonateSign"):WaitForChild("SurfaceGui"):WaitForChild("Frame")
		local MarketplaceService = game:GetService("MarketplaceService")
		Template.Id.Value = v
		local Info = MarketplaceService:GetProductInfo(v)
		Template.Name = v
		Template.Text = Info.PriceInRobux.."$"
	end
	for i, v in pairs(userTShirts) do
		local Template = script.Template:Clone()
		Template.Parent = plr.Backpack.DonateSign.DonateSign.SurfaceGui.Frame
		local MarketplaceService = game:GetService("MarketplaceService")
		Template.Id.Value = v
		local Info = MarketplaceService:GetProductInfo(v)
		Template.Name = v
		Template.Text = Info.PriceInRobux.."$"
	end


end)

1 Like

The numbers inside of userGamepasses is a player Id right?

Yes, that ID belongs to “CloneTrooper1019”.

I am getting 3 times the gamepasses I have, that is if I have 8 gamepasses, 24 are printed, they are tripled, I wanted to know if you know a solution.