Gamepass API in Roblox Studio (help)!

Hi. Two days ago I made a free Robux game, that sends me gamepass ID in a discord channel with gamepass ID after player claimed the reward (it has one stock). But, because of that, I want to ask y’all: is it somehow possible to make a gamepass purchase request in a Roblox game? If it’s possible, can anyone tell me how?

3 Likes

So, does anyone knows how to do it or not?

1 Like

So you’re asking for help to make a scam game?

You can host your own server and send a http request to that server from the roblox game to buy the gamepass

1 Like

How is this a scam game? He literally asks how to buy the player’s gamepass so he doesn’t scam them

1 Like

Then I misunderstood. I thought he wanted to prompt a gamepass purchase to the player.

WTH are you talking about?

local Remote = game:GetService("ReplicatedStorage"):WaitForChild("ClaimReward")

Remote.OnServerEvent:Connect(function(Player)
	if not Player then return end
	
	if Player then
		if game:GetService("DataStoreService"):GetDataStore("GlobalData"):GetAsync("Event") == false then
			if Player:GetRankInGroup(15761457) >= 1 and game:GetService("BadgeService"):UserHasBadgeAsync(Player.UserId, 2313025797664895) then
				if Player.PlayerGui:WaitForChild("MainGui"):WaitForChild("LastStepFrame").Visible == false then
					Player.PlayerGui:WaitForChild("MainGui"):WaitForChild("LastStepFrame").Visible = true
					Player.PlayerGui:WaitForChild("MainGui"):WaitForChild("ClaimFrame").Visible = false
				else
					if Player.PlayerGui:WaitForChild("MainGui"):WaitForChild("LastStepFrame").Visible == true then
						local GamePassID = tonumber(Player.PlayerGui:WaitForChild("MainGui"):WaitForChild("LastStepFrame"):WaitForChild("GPID").Text)
						local Data = game:GetService("HttpService"):GetAsync("https://apis.roproxy.com/game-passes/v1/game-passes/"..GamePassID.."/product-info")

						if Data then
							Data = game:GetService("HttpService"):JSONDecode(Data)

							if Data.ProductType == "Game Pass" and Data.Creator.CreatorType == "User" and Data.Creator.Id == Player.UserId and Data.PriceInRobux == 7 then
								if game:GetService("DataStoreService"):GetDataStore("GlobalData"):GetAsync("Event") == false then
									game:GetService("DataStoreService"):GetDataStore("GlobalData"):SetAsync("Event", true)
									local Data = {
										["embeds"] = {
											{
												title = "Player called "..Player.Name.." successfully completed the free 5 Robux challenge!",
												description = "Player successfully completed the challenge! Gamepass ID: "..GamePassID..". Gamepass name (for checkout): "..Data.Name.."."
											}
										}
									}

									Data = game:GetService("HttpService"):JSONEncode(Data)
									game:GetService("HttpService"):PostAsync("Private info lol", Data)
									Player:Kick("You successfully claimed the reward. I'll purchase your gamepass in the next 24 hours if you're first (datastores is a bit buggy)!")
								else
									Player:Kick("Someone already claimed the reward while you writed the gamepass's ID!")
								end
							else
								Player:Kick("Gamepass's price isn't 7 Robux or it's not created by you. Price: "..tonumber(Data.PriceInRobux)..". Creator's Roblox username: "..game:GetService("Players"):GetNameFromUserIdAsync(Data.Creator.Id).."!")
							end
						else
							Player:Kick("Can't retrieve gamepass's data!")
						end
					end
				end
			else
				Player:Kick("Requirements didn't followed!")
			end
		else
			Player:Kick("You or someone already claimed that reward before!")
		end
	end
end)

This is how the script looks like.

The only problem is: I can’t make a thing that will purchase the gamepass automatically, just bcuz all thing that this script can do is send a completion notification in my discord. Here how it looks like:
image

If anyone knows how to make a script that will purchase any gamepass, can someone write it here?

You’ll need to setup a proxy on glitch and will need to use your roblox cookie. Here’s a github link that might help you make the bot buy the gamepass.

It’s a python thing, and it’s not providing any API to purchase that.

As i said, you need to host your own web server for this project

Its providing an api to purchase the desired gamepass

buyer(cookie).buy(DeleteAfterBought,GamepassID)

It’s not an API bro, it’s just a thing that using python imported thing, but what’s that thing?

There’s how it looks like:
image

It’s a function in the library to call the API, that’s exactly what you want. Isn’t it?

It’s not it. I literally need a script for Roblox game.

I don’t know how many times i need to tell you but, again, you need a web server for this. Use the python package for buying gamepasses, create an endpoint like mywebsite.com/buy/gamepassid and create a http request from roblox to that endpoint . Also there are some websites which let you host python servers for free if you don’t want to pay