學習
引擎類別
PolicyService
無法建立
服務
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
繼承成員

API 參考
方法
CanViewBrandProjectAsync
暫停
功能: Basic
PolicyService:CanViewBrandProjectAsync(
player:Player, brandProjectId:string
參數
player:Player
brandProjectId:string
返回
範例程式碼
伺服器端程式碼範例
-- 在 ServerScriptService 中
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PolicyService = game:GetService("PolicyService")
-- 在 ReplicatedStorage 中預創建的 RemoteEvent
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local brandedAsset = ReplicatedStorage:WaitForChild("BrandedAsset")
local defaultAsset = Instance.new("Part")
Players.PlayerAdded:Connect(function(player)
-- PolicyService:CanViewBrandProjectAsync 僅能從伺服器呼叫
local success, canView = pcall(function()
return PolicyService:CanViewBrandProjectAsync(player, "BRP-0123456789")
end)
if success and canView then
RemoteEvent:FireClient(player, brandedAsset)
else
RemoteEvent:FireClient(player, defaultAsset)
end
end)
客戶端代碼範例
-- 在 StarterPlayerScripts 中
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- 在 ReplicatedStorage 中預先創建的 RemoteEvent
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent.OnClientEvent:Connect(function(partToLoad)
local clonedPart = partToLoad:Clone()
clonedPart.Parent = workspace
end)

GetPolicyInfoForPlayerAsync
暫停
功能: Basic
PolicyService:GetPolicyInfoForPlayerAsync(player:Instance):Dictionary
參數
player:Instance
範例程式碼
獲取玩家的政策資訊
local PolicyService = game:GetService("PolicyService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local success, result = pcall(function()
return PolicyService:GetPolicyInfoForPlayerAsync(player)
end)
if not success then
warn("政策服務錯誤: " .. result)
elseif result.ArePaidRandomItemsRestricted then
warn("玩家無法與付費隨機物品生成器互動")
end
取得玩家的政策資訊
local PolicyService = game:GetService("PolicyService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local success, result = pcall(function()
return PolicyService:GetPolicyInfoForPlayerAsync(player)
end)
if not success then
warn("PolicyService 錯誤: " .. result)
elseif not result.IsEligibleToPurchaseCommerceProduct then
warn("玩家不符合購買商品的條件")
end

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。