PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Game Passes – One-Time Purchases

Game Passes – One-Time Purchases

Oct 26 2018, 5:55 PM PST 15 min

Game passes allow Roblox developers to create special passes that can only be bought once per player using Robux. Examples are special access to a restricted area, an in-game avatar item, or a permanent power-up.

Game passes are free to create and sell — you don’t need to join the Builders Club, although members will earn a much higher percentage of Robux for each game pass sold.

Creating a Game Pass

To make a new game pass, go to the Create page on the Roblox website. Once there, make sure that the My Creations tab is selected and that “Games” is selected in the left column.

Now follow these steps to create a game pass:

  1. Determine the game you want to create a pass for.
  2. In the settings drop-down menu on the right-hand side, select Create Game Pass.

Create an Icon

Game passes require an image of exactly 150×150 pixels. These steps will help you create a custom icon for the pass.

  1. Save the following template (GamePassTemplate.png) for a circular game pass icon to your computer by right-clicking the image and selecting Save Image As….
  1. In an image editor or drawing application, fill in the blank circular area with some cool artwork.
  1. Save the game pass image with a new file name (if you plan to create more than one pass for your game, you shouldn’t save over the original template file).

Upload the Pass

The last step in the creation process is uploading the pass.

  1. Back on the Roblox website, click the small button next to Find your image.
  1. Find the game pass image on your computer and confirm that you’d like to upload it.

  2. Type in a name and description for the game pass. Remember that this is what players will see on your game’s page, so be creative and write something that will make players want to buy the pass!

  3. When you’re ready, click Preview. On the next screen, review the details for the game pass and click Verify Upload.

Configuring the Game Pass

Once you’ve created the game pass, it will appear on the My CreationsGame Passes page. However, you need to set up the pass so players can buy it.

  1. Select Configure from the right-side pull down menu for the new pass.
  1. Click the toggle switch by Item for Sale to make the pass available.

  2. Set the price (in Robux) for players. Notice that the price affects how many Robux you will earn for each sale as the game’s creator.

  1. Click the Save button to confirm your settings.

Giving the Game Pass an Effect

Once a player buys a game pass, they will naturally expect to get its special ability or bonus when they start playing. This does not happen automatically, so you must check which players already own the pass and assign the ability/bonus to them.

This example script checks when any player enters the game and then checks if they own the game pass with the matching ID set in the variable gamePassID.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 0000000  -- Change this to your game pass ID

local function onPlayerAdded(player)

	local hasPass = false

	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)

	-- If there's an error, issue a warning and exit the function
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end

	if hasPass == true then
		print(player.Name .. " owns the game pass with ID " .. gamePassID)
		-- Assign this player the ability or bonus related to the game pass
		--
	end
end

-- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function
Players.PlayerAdded:Connect(onPlayerAdded)

Prompting In-Game Purchases

Players can buy game passes directly from your game’s main page by clicking the Store tab and browsing the game passes you’ve made available to them:

However, it’s also a great idea to offer in-game purchases to players through a shop or vendor NPC within the game. Let’s explore an example of how to prompt the player to buy a game pass from within the game.

Server-Side Code

This code should be located in a Script object (not a LocalScript) within ServerScriptService so the server can handle the ability or bonus given to the player.

-- This code should be in a 'Script' object within 'ServerScriptService'
local MarketplaceService = game:GetService("MarketplaceService")

local gamePassID = 0000000  -- Change this to your game pass ID

-- Function to handle a completed prompt and purchase
local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)

	if purchaseSuccess == true and purchasedPassID == gamePassID then
		print(player.Name .. " purchased the game pass with ID " .. gamePassID)
		-- Assign this player the ability or bonus related to the game pass
		--
	end
end

-- Connect 'PromptGamePassPurchaseFinished' events to the 'onPromptGamePassPurchaseFinished()' function
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)

Client-Side Code

This code can be placed in a LocalScript and the promptPurchase() function can be called when the player presses a Articles/Creating GUI Buttons|button, when their character touches a part, or whatever fits your game design.

-- This code should be within a 'LocalScript' object
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
 
local gamePassID = 0000000  -- Change this to your game pass ID
 
-- Function to prompt purchase of the game pass
local function promptPurchase()

	local player = Players.LocalPlayer
	local hasPass = false

	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)

	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end

	if hasPass == true then
		-- Player already owns the game pass; tell them somehow
	else
		-- Player does NOT own the game pass; prompt them to purchase
		MarketplaceService:PromptGamePassPurchase(player, gamePassID)
	end
end

As you can see, game passes are a great way to sell special abilities, bonuses, and permanent power-ups to players while earning some Robux at the same time. We hope this article helps you add fun new game passes to your own games!

Tags:
  • pass