Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I get a gamepass's game?

Asked by 3 years ago

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.

0
What do you mean how to get a gamepasse's game? can you provide an example? sne_123456 439 — 3y
0
There is no native API that is capable of that Ziffixture 6913 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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!

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

Answer this question