Plugin for Importing Gamepass data [FREE]

How to Use:

  1. Ensure that your game is published and that HttpService.HttpEnabled is set to true
  2. Simply click the plugin button to activate the script
  3. Locate the script inside ReplicatedStorage

To utilize the data, all you need to do is require it. The returned data contains an array of Gamepass information obtained from game.MarketplaceService:GetProductInfo

Learn more about GetProductInfo here

Importing the data via the plugin offers the advantage of immediate access to all game pass data and metadata without the need to query it from Roblox

Motivation:

The creation of this tool was spurred by demand within the community. It provides a simple solution to a common problem

For more context, check out these Feature requests:

How it Works:

The plugin requires permission for HTTP requests and script writing. While this might sound daunting, let me reassure you about its purpose

Firstly, the plugin sends a request to retrieve all Gamepasses within a game universe. Then, it utilizes this data to query information from Roblox through MarketplaceService:GetProductInfo. Finally, the plugin stores this information inside a ModuleScript located in ReplicatedStorage

Get the plugin here

Please do not make plugins solely for importing scripts, or supply a separate link to the model (ModuleScript)

Installing a plugin, clicking the button and removing the plugin takes much longer than just dragging a script to the correct place.

1 Like

@xChris_vC

It simply creates a new script that stores the Gamepass information, I don’t understand the problem you have with the plugin, can you elaborate?

Ah, then I misinterpreted your post. It sounded like you made a module that gets the actual gamepass data in-game, rather than manually with a Studio plugin.

Anyway, it would still be more useful if you fetched this gamepass metadata with a module (Module:GetAllGamepasses()) so you can make dynamic shops where prices update instantly.

I designed this plugin based on my use case which is to have static data available before runtime, this is to prevent errors from failed Http requests and avoid rate limits

To update the gamepass data simply activate the plugin by clicking the button, it will update the same modulescript no matter where you put it or rename it (this is automatically done every time you start up Roblox Studio to ensure you have the most up to date data of your Gamepasses)

For your specific use case you can either fork the source code or write a different script to overwrite at a certain interval

(I don’t see the need or have a personal use case since most of my gamepasses rarely change in price)

Source Code
local TEST_ENABLED = false
local BEESWARMSIMULATOR = 601130232

local HTTP_NOT_ENABLED = "HttpEnabled is not enabled, please run 'game.HttpService.HttpEnabled = true' in the Command Bar"
local GAME_NOT_PUBLISHED = "Game is not published, please publish game to use service"

return function(plugin: Plugin)
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

	local CollectionService = game:GetService("CollectionService")

	local HttpService = game:GetService("HttpService")

	local MarketplaceService = game:GetService("MarketplaceService")

	local TAG = "GAMEPASSIMPORT"
	
	do
		if not HttpService.HttpEnabled then
			warn(HTTP_NOT_ENABLED)
		end

		if game.GameId == 0 and not TEST_ENABLED then
			warn(GAME_NOT_PUBLISHED)
		end
	end

	local function findModule(): ModuleScript?
		return CollectionService:GetTagged(TAG)[1]
	end

	local function createModule(): ModuleScript
		local Module: ModuleScript = Instance.new("ModuleScript")
		Module.Name = "Gamepasses"
		Module:AddTag(TAG)
		Module.Parent = ReplicatedStorage
		return Module
	end

	local function getGamepasses()
		local UNIVERSE_ID = if game.GameId == 0 then BEESWARMSIMULATOR else game.GameId

		local result = HttpService:GetAsync(`https://games.roproxy.com/v1/games/{UNIVERSE_ID}/game-passes?limit=100&sortOrder=Asc`)
		result = HttpService:JSONDecode(result)
		return result.data
	end

	local function importGamepasses()
		local gamepasses = getGamepasses()

		local cache = {}

		for _, v in gamepasses do
			local gamepassInfo = MarketplaceService:GetProductInfo(v.id, Enum.InfoType.GamePass)
			table.insert(cache, gamepassInfo)
		end

		local module = findModule()
		if not module then
			module = createModule()
		end

		local source = HttpService:JSONEncode(cache)
		module.Source = `local HttpService = game:GetService("HttpService"); return HttpService:JSONDecode('{source}')`
		
		warn("Import success, find at ReplicatedStorage")
	end

	local toolbar: PluginToolbar = plugin:CreateToolbar("Gamepass Importer")
	local button: PluginToolbarButton = toolbar:CreateButton("Gamepass Importer", "Import Gamepasses", "rbxassetid://14978048121")

	button.ClickableWhenViewportHidden = true
	button.Enabled = true

	button.Click:Connect(function()
		if not HttpService.HttpEnabled then
			warn(HTTP_NOT_ENABLED)
			return
		end

		if game.GameId == 0 and not TEST_ENABLED then
			warn(GAME_NOT_PUBLISHED)
			return
		end

		importGamepasses()
	end)

	importGamepasses()
end