Gamepass Search

I was trying to make a donation game, but I would know that I need to use something to detect the player’s gamepasses and items. But it didn’t work well. I tried to search through Roblox DevForum for links to the gamepass searcher that works but I couldn’t find any; when I paste them in my browser, it detects classic items and not gamepasses. Here is my code and I appreciate the help, since this is actually confusing!

script that’s run legacy is client (script in workspace)

local HTTPService = game:GetService("HttpService")
local Market = game:GetService("MarketplaceService")

-- Cache results for 5 minutes
local cache = {}
local CACHE_DURATION = 300

-- REPLACE YOUR getPlayerAssets() WITH THIS:
local function getPlayerAssets(player)
	-- Return cached data if available
	if cache[player.UserId] and (os.time() - cache[player.UserId].timestamp < CACHE_DURATION) then
		return cache[player.UserId].data
	end

	local items = {}

	-- 1. Try official inventory API first
	local success, inventory = pcall(function()
		local response = HTTPService:GetAsync(
			"https://inventory.roblox.com/v1/users/"..player.UserId.."/assets/collectibles?limit=100",
			true -- Enable caching
		)
		return HTTPService:JSONDecode(response).data
	end)

	if success and inventory then
		-- Add owned items
		for _, item in ipairs(inventory) do
			if item.isForSale then
				table.insert(items, item.assetId)
			end
		end
	else
		-- 2. Fallback to roproxy catalog (only if inventory fails)
		local success, catalog = pcall(function()
			local response = HTTPService:GetAsync(
				"https://catalog.roproxy.com/v1/search/items/details?Category=3&Limit=30&CreatorName="..player.Name,
				true
			)
			return HTTPService:JSONDecode(response).data
		end)

		if success and catalog then
			for _, item in ipairs(catalog) do
				table.insert(items, item.id)
			end
		end
	end

	-- Cache results
	cache[player.UserId] = {
		data = items,
		timestamp = os.time()
	}

	return items
end

script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	if plr and plr:FindFirstChild("Board") then
		local board = script.Parent.Parent
		if board and board:FindFirstChild("Values") and board.Values:FindFirstChild("Owner") then
			local boardName = board.Name
			local assets = getPlayerAssets(plr) -- Now uses the improved version
			game.ReplicatedStorage.DonationButtons:FireServer(boardName, assets)
		end
	end
end)

serverscriptservice script

local Market = game:GetService("MarketplaceService")

local function CloneAssets(boardName, assets)
	local board = game.Workspace.Boards:FindFirstChild(boardName)
	if not board then return end

	local frame = board.DonationBoard.SurfaceGui.DonationFrame

	-- Clear existing buttons
	for _, child in ipairs(frame:GetChildren()) do
		if child:IsA("Frame") and child.Name ~= "Template" then
			child:Destroy()
		end
	end

	-- Create new buttons
	for _, assetId in ipairs(assets) do
		local success, data = pcall(function()
			return Market:GetProductInfo(assetId)
		end)

		if success and data and data.IsForSale then
			local button = script.Template:Clone()
			button.Name = "Donate_"..assetId
			button.PurchaseButton.Text = data.Name.."\n"..data.PriceInRobux
			button.Visible = true

			-- Store asset ID
			local idValue = button:FindFirstChild("AssetId") or Instance.new("IntValue")
			idValue.Name = "AssetId"
			idValue.Value = assetId
			idValue.Parent = button

			button.Parent = frame
		end
	end
end

game.ReplicatedStorage.DonationButtons.OnServerEvent:Connect(function(plr, boardName, assets)
	-- Validate board name is a string
	if typeof(boardName) ~= "string" then
		warn("Invalid board name received:", boardName)
		return
	end

	-- Validate assets is a table
	if typeof(assets) ~= "table" then
		warn("Invalid assets format received")
		return
	end

	-- Get board reference
	local board = game.Workspace.Boards:FindFirstChild(boardName)
	if not board then
		warn("Board not found:", boardName)
		return
	end

	-- Claim the board
	plr:WaitForChild("Board").Value = boardName
	board.Start.ProximityPrompt.Enabled = false
	board.Values.Owner.Value = plr.Name

	-- Update board UI
	board.Player.SurfaceGui.Text.Text = plr.DisplayName.."'s Board"
	board.Time.SurfaceGui.Text.Text = "Best Time: "..plr.leaderstats.BestTime.Value
	board.Played.SurfaceGui.Text.Text = "Played: "..tostring(plr.leaderstats.Plays.Value)
	board.Raised.SurfaceGui.Text.Text = "Raised: "..tostring(plr.Values.Raised.Value)
	board.Donated.SurfaceGui.Text.Text = "Donated: "..tostring(plr.Values.Donated.Value)
	board.Screen.BrickColor = BrickColor.new("Cyan")
	board.Timer.SurfaceGui.Text.Text = "Click the Start button to play!"

	-- Create donation buttons
	CloneAssets(boardName, assets)
end)

Additionally, I feel like my script is wrong but I’m not sure.

5 Likes

What is the purpose of your script? To see if a player owns a gamepass or to get a gamepass?

I have absolutely zero experience with working with scripts like this, but I believe that it won’t work if the user’s inventory visibility isn’t set to Everyone.
I believe Roblox has added a way for a game to access a user’s inventory (albeit with a message asking for permission to) as Catalog Avatar Creator has a way to see your inventory’s items. Maybe try looking into that.

That’s exactly what I’m trying to do.

Do you know what that thing is?

this? https://create.roblox.com/docs/reference/engine/classes/AvatarEditorService#PromptAllowInventoryReadAccess

something that can get all of the gamepasses
like this that wont work
https://www.roproxy.com/users/inventory/list-json?assetTypeId=34&nextPageCursor=&itemsPerPage=100&pageNumber=&sortOrder=Desc&userId=4211919501

if that thing you gave me is, can you put that in a script with a few lines?

Additionally:

Yeah that end point that lets you filter by assetType has been disabled. The swagger can be checked here.

Hopefully this other method works for you!

???


It looks like that wouldn’t work… my gamepasses arent showing up

Did you not read the other half of my message?

“You’re required to create an API key for all Open Cloud interactions; you can learn how to do that here. This will require you to add an x-api-key header to all of your GET requests, so study how either HttpService:GetAsync or HttpService:RequestAsync enables you to do that.”

1 Like

Donation games are still trending ey.
Well, unfortunately the only way to get gamepasses of a specific user is to kinda use the Roblox web API.

Besically access the roblox website trough the actual game to look trough it for a user then look for their games and then look trough each game for that game’s gamepasses.

But that is easier said than done, cause every time youre sending a request to look for something in the website, well, youre sending a request from the roblox servers to the roblox servers.
Because of that Roblox has blocked requests from roblox to roblox, if that is actually misused it can cause alot of problems for them.

So whats the second best thing you ask ?

Make a proxy to basically say "hi roblox, this is me, im making this request, now you can know what IP is making this request so you can punish it if its doing something malicious "

You can always use a public proxy like RoProxy for testing but as you have noticed, alooooot of people are using that and since its actually a server thats running it can sometimes heat up and drop some requests.

So you kinda have to make your own thing and keep it secured to only yourself.

But, if you have never made proxies or ran servers its a hard thing to do.

So you end up either relying on the public proxies or strive to learn how to make ur own (or hire someone to do it for you)

After that its fairly easy, just ask for a list of gamepasses each time a player joins, proxy go brr and return gamepasses from a specific user, you place the gamepasses in buttons or a table tied to buttons and you have ur self a donation game.

Naturally you will encounter the same issue everyone encounters which is:
Gamepasses were never meant to be used in such a way, Roblox never intended them to be used for donations or be distributed in games that aint owned by the owner of the gamepass.
So they cache, and if a bad actor knows how these systems work, they can bypass almost all security checks you implement.

So overall lets say, that donation games are a really complex thing to do even if they look really simple.
The whole donation system is based on a work around that was never intended to work as such in the roblox engine. So you will end up using tools and resources that are not from the roblox engine (aka, you have to learn how to run servers)

But why do all this ?
Donation games are not actually successful.
Mostly cause they are meant for people to spend robux, so why would people go to your game to spend their robux if they can do it in an already solid Donation game and get the same and even better effect. You know what im talking about.

I can assure you, making an obby is actually way more successful than running a donation game.
Ive spent 2 years developing the most optimal donation system but even so.
Any donation game you try to make, regardless of the scope will get you around 30 to 40 players and will make quite little robux cause ppl dont tend to spend their robux in donation games which are not top 3.

This game I’m making isn’t just a donation game, it’s a reaction time game too. I’m currently making a board(later duplicated) that has reaction time stuff(successful) and donation stuff(unsuccessful). So the game’s not just a donation game.