GetPolicyInfoForPlayerAsync
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
Returns policy information about a player which is based on geolocation, age group, and platform. The structure of the returned dictionary is as follows:
Name | Type | Description |
---|---|---|
ArePaidRandomItemsRestricted | Boolean | Whether the player can interact with paid random item generators. |
IsSubjectToChinaPolicies | Boolean | See here for details. |
AllowedExternalLinkReferences | Array of strings | Which external link references are allowed in a country/region. |
IsPaidItemTradingAllowed | Boolean | Whether the player can trade virtual items that were purchased with in-game or real-world currency. |
Exceptions
Like any async call, this needs to be wrapped in a pcall
and error-handled properly. A full list of possible error messages and their reasons is as below:
Message | Reason |
---|---|
Instance was not a player | Dev's usage - The parameter is not a Player instance |
Players not found | Internal error - Players object missing |
This method cannot be called on the client for a non-local player | Dev's usage - This method cannot be called on the client for a non-local player |
GetPolicyInfoForPlayerAsync is called too many times | Internal error - GetPolicyInfoForPlayerAsync is called more than 100(current setting) times before http response coming back |
See also
LocalizationService/GetCountryRegionForPlayerAsync
, returns country/region code string according to player’s client IP geolocation
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The Player that you are getting policy information for |
Returns
Return Type | Summary |
---|---|
A dictionary containing information about the policy information of a given player |
Code Samples
Getting Policy Information for a Player
This code sample gets policy information for the local player and warns if they cannot interact with paid random item generators.
local PolicyService = game:GetService("PolicyService") local player = game.Players.LocalPlayer local result, policyInfo = pcall(function() return PolicyService:GetPolicyInfoForPlayerAsync(player) end) if not result then warn("PolicyService error: " .. policyInfo) elseif policyInfo.ArePaidRandomItemsRestricted then warn("Player cannot interact with paid random item generators") end