Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I get a gamepass's game?

I'm trying to load gamepass info, and I'd like to include the game that holds the gamepass. I've done a lot of googling, of course to no results.

2 comments

0

What do you mean how to get a gamepasse's game? can you provide an example?

0

There is no native API that is capable of that

2 answers

Your question is very vague, however, I think all you have to do is press create on the top of your roblox profile, then you will have a list of all your creations. Click the game you would like to add the gamepass to. Then it will show a 'configure place' page. You want to press back. Then it will take you to your game page. - You can also do this by going to your roblox profile and press creations and selecting your game. You then press store. There's an option that says 'add pass' If you click on that you can make your gamepass which is linked to your game!

Hope this helps!

I've made a very hacky solution:

local hs = game:GetService("HttpService")
local cache = {}

local function getPage(url)
	url = string.gsub(url,"www.roblox.com","rprxy.xyz")
	local resp
	if not cache[url] then
		local succ,err = pcall(function()
			resp = hs:GetAsync(url)
		end)
		if succ then
			cache[url] = resp
			return resp,true
		else
			warn(err)
			return nil,false
		end
	else
		return cache[url],true
	end
end

local function getGameName(url)
	local resp,succ = getPage(url)
	if succ then
		local segments = string.split(resp,"<")
		for _,segment in pairs(segments) do
			if string.find(segment,"img alt=") then
				return string.split(segment,'"')[2]
			end
		end
	end
end
local function getGameId(url)
	local resp,succ = getPage(url)
	if succ then
		local segments = string.split(resp,"<")
		for _,segment in pairs(segments) do
			if string.find(segment,'a href="') then
				return string.split((string.split(segment,'=')[3]),'&')[1]
			end
		end
	end
end

To use it, you would call either getGameName or getGameId with the gamepass' url (e.g. https://www.roblox.com/game-pass/2725211/Premium-Garage). It takes a while to load, and is likely to break in the future.

This discussion is preserved as it was. New answers, comments, and votes are closed.