通行证

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

通行证 让你向用户收取一次性 Robux 费用以访问体验内的特殊权限,例如进入限制区、体验虚拟形象物品或永久升级。

创建通行游戏通行证

要创建通行游戏通行证:

  1. 前往 创作 并选择一个体验。
  2. 前往 货币化 > 通行证
  3. 点击 创建通行证
  4. 上传一个图像以显示为通行证标志。确保图像不超过 512x512 像素,不包含圆圈边界之外的重要细节,并且处于 .jpg.png.bmp 格式中。
  5. 输入通行游戏通行证的名称和描述。
  6. 点击 创建通行证
Good circular trimming

>

Bad circular trimming

>

获取通行证 ID

要使用脚本,您需要一个通行证 ID。要获取通行证 ID:

  1. 前往 货币化 > 通行证

  2. 将鼠标悬停在游戏通行证行证缩略图上,单击 按钮,然后从上下文菜单中选择 复制资产ID

出售通行游戏通行证

你可以以两种方式出售通行证:

在你的体验中

要在体验中实现并出售通行证,请调用 MarketplaceService 函数。

使用 GetProductInfo() 来检索通行游戏通行证的信息,例如名称和价格,然后向用户显示该通行证。你可以在体验市场内出售通行证,例如。对于通行证,第二个参数必须为 Enum.InfoType.GamePass


local MarketplaceService = game:GetService("MarketplaceService")
-- 将占位符 ID 替换为您的通行证 ID
local productId = 000000
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(productId, Enum.InfoType.GamePass)
end)
if success and productInfo then
-- 检查产品是否待促销
if productInfo.IsForSale then
-- 显示产品信息
-- 将打印声明替换为用户界面代码以显示通行游戏通行证
print("Pass Name: " .. productInfo.Name)
print("Price in Robux: " .. productInfo.PriceInRobux)
print("Description: " .. productInfo.Description)
else
print("This product isn't for sale")
end
end

使用 PromptPurchase() 要求用户购买通行证,如果用户尚未在道具中拥有通行证。当用户执行按钮按钮或与供应商 NPC 交谈等操作时,您可以调用此函数。


local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
-- 将占位符 ID 替换为您的通行证 ID
local passID = 0000000
-- 提示购买通行证
local function promptPurchase()
local player = Players.LocalPlayer
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passID)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass then
-- 显示消息,告诉用户他们已经拥有通行游戏通行证
else
-- 提示购买通行证
MarketplaceService:PromptGamePassPurchase(player, passID)
end
end

使用 PromptGamePassPurchaseFinished() 来处理完成的通行证提示和购买,并为用户分配与通行游戏通行证相关的权限。

将脚本放置在 ServerScriptService 内,以便服务器处理用户的通行权限。


local MarketplaceService = game:GetService("MarketplaceService")
-- 将占位符 ID 替换为您的通行证 ID
local passID = 0000000 -- 将其更改为您的通行证 ID
-- 处理完成的提示和购买
local function onPromptPurchaseFinished(player, purchasedPassID, purchaseSuccess)
if purchaseSuccess and purchasedPassID == passID then
print(player.Name .. " purchased the Pass with ID " .. passID)
-- 为用户分配与通行证相关的能力或奖游戏通行证
end
end
-- 将提示游戏通行证购买完成事件连接到函数
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptPurchaseFinished)

在你的体验之外

要在体验详情页面的 商店 选项卡上出售通行证:

  1. 前往 货币化 > 通行证 .
  2. 将鼠标悬停在通行证上,然后单击 菜单。
  3. 选择你想要出售的通行证。
  4. 选择 销售
  5. 启用 出售物品 切换。
  6. Robux 价格 字段中,输入您想向用户收取通行游戏通行证费用的 Robux 数量。你输入的价格会影响每次促销售获得的 Robux 数量。你输入的价格会影响每次促销售获得的 Robux 数量。最低价格为 1 Robux,最高价格为 10亿 Robux。
  7. 点击 保存更改 。通行证会填充体验详情页面的 存储 选项卡。

分配通行证权限

您必须手动为购买您的通行证的用户分配通行证权限。要做到这一点,用户加入您的体验时,使用 PlayerAdded 来检查他们是否已拥有通行证,并为他们分配通行证权限。

将脚本放置在 ServerScriptService 内,以便服务器处理用户的通行权限。


local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
-- 将占位符 ID 替换为您的通行证 ID
local passID = 0000000
local function onPlayerAdded(player)
local hasPass = false
-- 检查用户是否已拥有通行游戏通行证
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passID)
end)
if not success then
-- 发出警告并退出函数
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass then
-- 为用户分配与通行证相关的能力或奖游戏通行证
print(player.Name .. " owns the Pass with ID " .. passID)
end
end
-- 将玩家添加事件连接到函数
Players.PlayerAdded:Connect(onPlayerAdded)

通行分析

使用通行证分析来分析个人通行证的成功,识别趋势,并预测潜在的未来收益。

通过分析,你可以:

  • 查看你在指定时间段内的最高通行证。
  • 在时间序列图上展示最多八个最畅销的物品来分析整体销售和净收入。
  • 监控您的目录并按销售额和净收入排序项目。

要访问通行证分析:

  1. 前往 创作 并选择一个体验。
  2. 前往 货币化 > 通行证 .
  3. 选择 分析 标签。