How do you get every gamepass of the game without hardcoding it?

i want to make a script that gets every gamepass from the game without having to hardcode/script each gamepassid manually

local marketplaceservice = game:GetService('MarketplaceService')

local gamepasses = {810807833, 802697590}

for _, gamepass in pairs(gamepasses) do
	local asset = marketplaceservice:GetProductInfo(gamepass, Enum.InfoType.GamePass)
	local template = gamepasstemplate:Clone()
	template.Parent = gamepassesframe.Frame
	template.Name = asset.Name
	template.GamepassName.Text = asset.Name
	template.GamepassDescription.Text = asset.Description
	template.robux.GamepassPrice.Text = asset.PriceInRobux
	template.GamepassIcon.Image = 'rbxassetid://' .. asset.IconImageAssetId
end

is there any way to make the script get all gamepasses automatically without having to manually insert each id in (if you cannot solve this it is fine i just wanna kinda prevent annoyances in the future)

Are you trying to make a gamepasses ui and if the button was triggered it would show gamepass purchase prompt if the pass wasnt owned by player?

yes. thats what im currently working on making the script do

local LocalPlayer = game.Players.LocalPlayer
local marketplaceservice = game:GetService('MarketplaceService')

local gamepasses = {810807833, 802697590}

for _, gamepass in pairs(gamepasses) do
	local asset = marketplaceservice:GetProductInfo(gamepass, Enum.InfoType.GamePass)
	local template = gamepasstemplate:Clone()
	template.Parent = gamepassesframe.Frame
	template.Name = asset.Name
	template.GamepassName.Text = asset.Name
	template.GamepassDescription.Text = asset.Description
	template.robux.GamepassPrice.Text = asset.PriceInRobux
	template.GamepassIcon.Image = 'rbxassetid://' .. asset.IconImageAssetId
--[[ 
 you already did it tbh, i believe this code is for passes ui so if you dont have image button, text button you're required to make one here is addition for your code

(so for i,v loop you already check the gamepasses ui all you need to do is to add button)
]]--

	template.button.MouseButton1Clicked:Connect(function()
		if marketplaceservice:UserOwnsGamePassAsync(LocalPlayer.UserId, gamepass) == true then --gamepass present as gamepass id
			print("owned")
		else
			marketplaceservice:PromptGamePassPurchase(LocalPlayer, gamepass)
		end
			
	end)

end

I hope this helps, goodluck with your games!

I don’t think so, but to get all the game passes:
There is a Web API for this
https://games.roblox.com/v1/games/universeId/game-passes?limit=100&sortOrder=Asc

i think i didnt explain my problem correctly. my bad

what i want to do is grab every gamepass from the game and put the ids into a table instead of this local gamepasses = {810807833, 802697590}

is there any way i can achieve this or no?

ohhhh i see, ill try and figure this out and see if it works

^^ this but youre gonna need a proxy for requests

https://games.roproxy.com/v1/games/GAMEID/game-passes?limit=100&sortOrder=Asc

may i ask how do i get this to work inside of a roblox script?

Use HttpService to post HTTP requests. There’s plenty of tutorials related to this already for Discord Webhooks, so I would recommend looking there for help on how to use HTTPService if the documentation isn’t sufficient :slight_smile: