一個 開發者產品 是用戶可以多次購買的物品或能力,例如遊戲內貨幣、彈藥或藥水。

創建開發者產品
要創建開發者產品:
- 前往 創作 並選擇一個遊戲。
- 前往 貨幣化 ⟩ 開發者產品。
- 點擊 創建開發者產品。
- 上傳一個圖像作為產品圖標。確保圖像不超過 512x512 像素,並且不包含圓形邊界外的重要細節,格式為 .jpg、.png 或 .bmp。
- 輸入產品的名稱和描述。
- 為產品選擇一個類別。該類別用於組織您遊戲內商店中的物品。
- 設定產品的 Robux 價格。最低價格為 1 Robux,最高價格為 10 億 Robux。
- 點擊 保存更改。
獲取開發者產品 ID
要使用腳本,您需要一個開發者產品 ID。要獲取產品 ID:
前往 貨幣化 ⟩ 開發者產品。
將鼠標懸停在產品縮略圖上,點擊 ⋯ 按鈕,然後從上下文菜單中選擇 複製資產 ID。

銷售開發者產品
在銷售開發者產品之前,請確保您正確處理銷售收據並授予用戶他們購買的產品。為此,您必須:
- 使用 ProcessReceipt API 來檢查購買收據。ProcessReceipt 自動讀取並確認用戶已在遊戲外購買產品。
- 驗證每個收據的 用戶 ID、開發者產品 ID 和收據狀態。
- 如果收據的狀態為 開放,則授予用戶他們購買的開發者物品。
- 對 ProcessReceipt API 回應一條確認收據的消息,並驗證已授予購買的物品。
您可以以兩種方式銷售開發者產品:
在您的遊戲內
要在遊戲內實現和銷售開發者產品,請調用 MarketplaceService 函數。
使用 GetProductInfo 來檢索有關開發者產品的信息,例如名稱和價格,然後將該產品顯示給用戶。例如,您可以在遊戲的市場中銷售該產品。對於開發者產品,第二個參數必須是 Enum.InfoType.Product。
local MarketplaceService = game:GetService("MarketplaceService")
-- 用您的開發者產品 ID 替換佔位符 ID
local productId = 000000
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(productId, Enum.InfoType.Product)
end)
if success and productInfo then
-- 顯示產品信息
-- 用 UI 代碼替換打印語句以顯示產品
print("開發者產品名稱: " .. productInfo.Name)
print("Robux 價格: " .. productInfo.PriceInRobux)
print("描述: " .. productInfo.Description)
end使用 GetDeveloperProductsAsync 來檢索與您的遊戲相關的所有開發者產品。此函數返回一個 Pages 對象,您可以檢查和過濾以構建遊戲內商店或產品列表 GUI。
local MarketplaceService = game:GetService("MarketplaceService")
local success, developerProducts = pcall(function()
return MarketplaceService:GetDeveloperProductsAsync()
end)
if success and developerProducts then
local firstPage = developerProducts:GetCurrentPage()
for _, developerProduct in firstPage do
-- 用 UI 代碼替換打印語句以顯示產品
print(field .. ": " .. value)
end
end使用 PromptProductPurchase 來提示遊戲內的產品購買。當用戶執行按鈕按下或與 NPC 供應商交談等操作時,可以調用此函數。
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- 用您的開發者產品 ID 替換佔位符 ID
local productId = 000000
local function promptProductPurchase()
local success, errorMessage = pcall(function()
MarketplaceService:PromptProductPurchase(player, productId)
end)
if success then
print("購買提示成功顯示")
end
end您還可以在 LocalScript 中組合函數。例如,您可以創建一個 UI 元素,如按鈕或供應商 NPC,然後使用 GetProductInfo() 將現有的開發者產品連接到該元素,檢查產品是否在售,並使用 PromptProductPurchase() 在用戶點擊時提示購買。
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local button = script.Parent
-- 用您的開發者產品 ID 替換佔位符 ID
local productId = 000000
-- 當用戶點擊 UI 按鈕時獲取產品信息
button.MouseButton1Click:Connect(function()
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(productId, Enum.InfoType.Product)
end)
if success and productInfo then
-- 檢查產品是否在售
if productInfo.IsForSale then
print("這個產品在售")
-- 提示產品購買
MarketplaceService:PromptProductPurchase(player, productId)
else
-- 通知產品不在售
print("該產品目前不在售。")
end
else
print("獲取產品信息時出錯: " .. tostring(productInfo))
end
end)在您的遊戲外
要在遊戲外啟用開發者產品購買,您必須使用 ProcessReceipt API。在用戶在您的遊戲詳細信息頁面的 商店 標籤中進行購買後,您必須使用 ProcessReceipt 來確認他們的購買並在他們進入遊戲後授予他們的物品。
啟用外部銷售
Roblox 在您的遊戲外顯示您的 已列出 開發者產品和遊戲通行證,包括在 Roblox 首頁、搜索結果中,以及在玩家購買 Robux 後的購買頁面上。玩家可以購買您的物品,然後帶著它加入您的遊戲。
要使開發者產品有資格進行外部銷售:
- 在 創作者中心 中,前往 貨幣化 ⟩ 商店。
- 將開發者產品標記為 已列出。
- 確認您已正確實施該產品的 ProcessReceipt。
遊戲通行證不需要 ProcessReceipt 修復,但它們也必須是 已列出 才能在您的遊戲外顯示。我們建議為每個開發者產品添加自定義圖標,以便玩家可以在外部界面上識別它;如果您不添加,Roblox 將顯示默認圖標。
有關 ProcessReceipt API 及其實現的更多信息,請參見 ProcessReceipt 頁面。
修復被標記的開發者產品
如果 Roblox 檢測到您的 已列出 開發者產品存在 ProcessReceipt 問題,則會在 創作者中心 ⟩ 貨幣化 ⟩ 商店 中顯示一個橫幅,該橫幅鏈接到受影響產品的報告。如果您的開發者產品不需要修復,則不會顯示橫幅或報告。
要解決被標記的開發者產品:
- 從橫幅中打開報告。報告列出了每個需要 ProcessReceipt 修復的 已列出 開發者產品,以及其產品名稱和產品 ID。
- 在 Roblox Studio 中打開您的遊戲,並修復被標記產品的 ProcessReceipt 實現。
- 發布您的遊戲。
- 在報告中,選擇已修復的產品並點擊 標記為已修復。
已修復的產品將離開報告,並再次有資格在您的遊戲外顯示。
限制
- 未列出的開發者產品永遠不會出現在 商店 或您的遊戲外。
- 在您的遊戲外銷售開發者產品不會改變您的標準收益或購買處理。
常見問題
只有當 Roblox 檢測到需要 ProcessReceipt 修復的已列出開發者產品時,您才會看到橫幅。如果您沒有看到橫幅,則不需要採取任何行動。
不。ProcessReceipt 報告僅適用於開發者產品。已列出的開發者產品和遊戲通行證都可以在您的遊戲外顯示和銷售。
不。外部銷售為玩家提供了額外的地方來查找和購買您的物品。您的購買處理和標準收益不變。
處理開發者產品購買
在用戶購買開發者產品後,您必須處理並記錄該交易。為此,請在 ServerScriptService 中使用 Script 來使用 ProcessReceipt 函數。
有關 ProcessReceipt API 及其實現的更多信息,請參見 ProcessReceipt 頁面。
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productFunctions = {}
-- 示例:產品 ID 123123 使用戶恢復到滿血
productFunctions[123123] = function(receipt, player)
local character = player.Character
local humanoid = character and character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Health = humanoid.MaxHealth
-- 表示購買成功
return true
end
end
-- 示例:產品 ID 456456 獎勵用戶 100 金幣
productFunctions[456456] = function(receipt, player)
local leaderstats = player:FindFirstChild("leaderstats")
local gold = leaderstats and leaderstats:FindFirstChild("Gold")
if gold then
gold.Value += 100
return true
end
end
local function processReceipt(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local player = Players:GetPlayerByUserId(userId)
if player then
-- 獲取與開發者產品 ID 相關的處理函數並嘗試運行它
local handler = productFunctions[productId]
local success, result = pcall(handler, receiptInfo, player)
if success then
-- 用戶已收到他們的物品
-- 返回 "PurchaseGranted" 以確認交易
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("處理收據失敗:", receiptInfo, result)
end
end
-- 無法授予用戶的物品
-- 返回 "NotProcessedYet" 並在用戶下次加入遊戲時重試
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- 設置回調
-- 這只能由一個伺服器端腳本執行一次
MarketplaceService.ProcessReceipt = processReceipt個性化您的遊戲內商店
您可以使用產品智能 API 來對開發者產品進行排序和推薦給用戶。個性化您的遊戲內商店有助於向每個用戶展示最相關的物品,提升參與度和收入。通過根據用戶偏好量身定制開發者產品,您可以改善其發現,增加轉換率,並解鎖新的貨幣化機會。
排名可銷售的開發者產品
RankProductsAsync 接受一個產品 ID 列表並返回這些產品的個性化排序列表。您可以使用此方法為用戶提供個性化的物品推薦,放在您的遊戲內商店中。

local MarketplaceService = game:GetService("MarketplaceService")
-- 創建一個您想要排名的產品數組
local productIdentifiers = {
{InfoType = Enum.InfoType.GamePass, Id = 123},
{InfoType = Enum.InfoType.Product, Id = 456},
{InfoType = Enum.InfoType.Product, Id = 789}
}
-- 進行保護調用以處理錯誤
local success, rankedProducts = pcall(function()
return MarketplaceService:RankProductsAsync(productIdentifiers)
end)
if not success then
error("排名產品失敗")
end
-- 將返回的物品加載到商店中
for i, rankedItem in ipairs(rankedProducts) do
local productIdentifier = rankedItem.ProductIdentifier
local productInfo = rankedItem.ProductInfo
-- ...
-- 將產品添加到商店的邏輯
end顯示您的頂級開發者產品
RecommendTopProductsAsync 接受一個 InfoType 值的數組,並返回用戶最有可能參與和購買的最多 50 件物品。您可以使用此方法在您的遊戲內商店中創建 "熱門推薦" 部分。
如果無法確定任何推薦,RecommendTopProductsAsync 將返回 0 件物品。
在少數情況下,對排名模型的調用可能會很慢。為了幫助防止用戶的延遲,我們建議使用 task.spawn 使對 RecommendTopProducts 的調用非阻塞。

local MarketplaceService = game:GetService("MarketplaceService")
-- 創建一個您想要包含在推薦中的產品類型數組 -- 此示例包括通行證和開發者產品
local productTypes = {Enum.InfoType.GamePass, Enum.InfoType.Product}
-- 進行保護調用以處理錯誤
local success, topRankedItems = pcall(function()
return MarketplaceService:RecommendTopProductsAsync(productTypes)
end)
if not success then
error("排名產品失敗")
end
-- 將返回的物品加載到商店中
-- 確保過濾掉任何不合格的物品,例如用戶不再能購買的開發者產品
for i, rankedItem in ipairs(topRankedItems) do
local productIdentifier = rankedItem.ProductIdentifier
local productInfo = rankedItem.ProductInfo
-- ...
-- 將產品添加到商店的邏輯
end開發者產品分析
使用開發者產品分析來分析單個產品的成功,識別趨勢,並預測潛在的未來收益。
通過分析,您可以:
- 查看您在選定時間段內的頂級開發者產品。
- 在時間序列圖上展示最多八個暢銷物品,以分析整體銷售和淨收入。
- 監控您的目錄並按銷售和淨收入對物品進行排序。
要訪問開發者產品分析:
- 前往 創作 並選擇一個遊戲。
- 前往 貨幣化 ⟩ 開發者產品。
- 選擇 分析 標籤。
