We use cookies on this site to enhance your user experience

Developer Products – In‑Game Purchases

Developer Products – In‑Game Purchases

Aug 29 2019, 9:18 AM PST 10 min

Developer products are items which players can buy more than once, making them perfect for in-game currency, ammo, or similar purchases.

Creating a Developer Product

To make a new developer product, 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 developer product:

  1. Determine the game you want to create a product for.
  2. In the settings drop-down menu on the right-hand side, select Configure Game.
  1. Select the Developer Products tab in the left column and then click the Create new button.
  2. On the product creation page, fill in all of the necessary boxes, then click Create.
  1. After creating the developer product, Roblox assigns it a unique ID. You’ll need this number when scripting developer products, but don’t worry if you forget a product ID — just return to the game configuration page where all of your developer products are neatly listed:

Scripting for Developer Products

To take full advantage of developer products, you’ll need to use scripting. Here are some common examples:

Getting a Game’s Developer Products

To gather data for all of the developer products in a game, use the MarketplaceService/GetDeveloperProductsAsync|GetDeveloperProductsAsync() method. This returns a Pages object that you can inspect and filter to build an in-game store, product list GUI, etc.

Getting Product Info

To get information (price, name, image, etc.) for a specific product, use the MarketplaceService/GetProductInfo|GetProductInfo() function with a second argument:

local MarketplaceService = game:GetService("MarketplaceService")

local productID = 0000000  -- Change this to your developer product ID

local productInfo = MarketplaceService:GetProductInfo(productID, Enum.InfoType.Product)

Prompting a Purchase

You can prompt a player to purchase one of your developer products with the MarketplaceService/PromptProductPurchase|PromptProductPurchase() method of MarketplaceService. In the following code, the promptPurchase() function can be called when the player presses a Articles/Creating GUI Buttons|button, talks to a vendor NPC, 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 productID = 0000000  -- Change this to your developer product ID
-- Function to prompt purchase of the developer product
local function promptPurchase()
	local player = Players.LocalPlayer
	MarketplaceService:PromptProductPurchase(player, productID)

After a purchase is made, it’s your responsibility to handle and record the transaction. This can be done inside a server-side script (Script) using the MarketplaceService/ProcessReceipt|ProcessReceipt callback. The function you define will be called repetitively until it returns Enum.ProductPurchaseDecision.PurchaseGranted.

-- This code should be in a 'Script' object within 'ServerScriptService'
local MarketplaceService = game:GetService("MarketplaceService")
local function processReceipt(receiptInfo)
	-- Find the player who made the purchase in the server
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		-- The player probably left the game
		-- If they come back, the callback will be called again
		return Enum.ProductPurchaseDecision.NotProcessedYet
	-- Output what product they bought
	print(receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId)
	-- IMPORTANT: Tell Roblox that the game successfully handled the purchase
	return Enum.ProductPurchaseDecision.PurchaseGranted

-- Set the callback (this can only be done once by one script on the server!)
MarketplaceService.ProcessReceipt = processReceipt
  • product
  • purchase