We use cookies on this site to enhance your user experience

Game Passes – Abilities and Bonuses: Code Sample 2

Game Passes – Abilities and Bonuses: Code Sample 2

Sep 06 2018, 6:06 PM PST

-- 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

-- Connect 'PromptGamePassPurchaseFinished' events to the 'onPromptGamePassPurchaseFinished()' function