Skip to main content

playerPolicyInfoUtil

A very simple utility module for retrieving a player's policy info safely.

playerPolicyInfoUtil.playerPolicyInfoPromise(localPlayer):andThen(function(playerPolicyInfo)
    print(playerPolicyInfo.ArePaidRandomItemsRestricted)
    print(playerPolicyInfo.AllowedExternalLinkReferences)
    print(playerPolicyInfo.IsPaidItemTradingAllowed)
    print(playerPolicyInfo.IsSubjectToChinaPolicies)
end):catch(function(defaultPlayerPolicyInfo, errorMessage)
    warn(string.format("Error retrieving player policy info because %s", errorMessage))
end)    

Types

PlayerPolicyInfo

interface PlayerPolicyInfo {
ArePaidRandomItemsRestrictedboolean
AllowedExternalLinkReferences{string}
IsPaidItemTradingAllowedboolean
IsSubjectToChinaPoliciesboolean
}

DEFAULT_PLAYER_POLICY_INFO

Constant
interface DEFAULT_PLAYER_POLICY_INFO {
ArePaidRandomItemsRestrictedfalse
AllowedExternalLinkReferences{}
IsPaidItemTradingAllowedfalse
IsSubjectToChinaPoliciesfalse
}
WARNING

Constant, not accessible within playerPolicyInfoUtil.

Functions

playerPolicyInfoPromise

playerPolicyInfoUtil.playerPolicyInfoPromise(playerPlayer) → Promise<PlayerPolicyInfo>

Returns a promise which is resolved with a read only policy info dictionary for the given player.

If the promise rejects, then the promise will reject with a read only copy of DEFAULT_PLAYER_POLICY_INFO and an error message.

playerPolicyInfoUtil.playerPolicyInfoPromise(somePlayer):andThen(function(policyInfo)
    print(policyInfo.ArePaidRandomItemsRestricted)
end):catch(function(defaultPlayerPolicyInfo, errorMessage)
    warn(defaultPlayerPolicyInfo, tostring(errorMessage))
end)
Read only policy info

The policy info table will be read-only, through table.freeze.

Show raw api
{
    "functions": [
        {
            "name": "playerPolicyInfoPromise",
            "desc": "Returns a [promise](https://eryn.io/roblox-lua-promise/) which is resolved with a *read only* policy info\ndictionary for the given player.\n\nIf the promise rejects, then the promise will reject with a *read only* copy of [DEFAULT_PLAYER_POLICY_INFO] and an error message.\n\n```lua\nplayerPolicyInfoUtil.playerPolicyInfoPromise(somePlayer):andThen(function(policyInfo)\n    print(policyInfo.ArePaidRandomItemsRestricted)\nend):catch(function(defaultPlayerPolicyInfo, errorMessage)\n    warn(defaultPlayerPolicyInfo, tostring(errorMessage))\nend)\n```\n\n:::note Read only policy info\nThe policy info table will be *read-only*, through [table.freeze](https://create.roblox.com/docs/reference/engine/libraries/table#freeze).\n:::",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<PlayerPolicyInfo>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 76,
                "path": "src/playerPolicyInfoUtil/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "PlayerPolicyInfo",
            "desc": " ",
            "fields": [
                {
                    "name": "ArePaidRandomItemsRestricted",
                    "lua_type": "boolean",
                    "desc": ""
                },
                {
                    "name": "AllowedExternalLinkReferences",
                    "lua_type": "{string}",
                    "desc": ""
                },
                {
                    "name": "IsPaidItemTradingAllowed",
                    "lua_type": "boolean",
                    "desc": ""
                },
                {
                    "name": "IsSubjectToChinaPolicies",
                    "lua_type": "boolean",
                    "desc": ""
                }
            ],
            "source": {
                "line": 27,
                "path": "src/playerPolicyInfoUtil/init.luau"
            }
        },
        {
            "name": "DEFAULT_PLAYER_POLICY_INFO",
            "desc": " \n\n\n:::warning\nConstant, not accessible within `playerPolicyInfoUtil`.\n:::",
            "fields": [
                {
                    "name": "ArePaidRandomItemsRestricted",
                    "lua_type": "false",
                    "desc": ""
                },
                {
                    "name": "AllowedExternalLinkReferences",
                    "lua_type": "{}",
                    "desc": ""
                },
                {
                    "name": "IsPaidItemTradingAllowed",
                    "lua_type": "false",
                    "desc": ""
                },
                {
                    "name": "IsSubjectToChinaPolicies",
                    "lua_type": "false",
                    "desc": ""
                }
            ],
            "tags": [
                "Constant"
            ],
            "source": {
                "line": 42,
                "path": "src/playerPolicyInfoUtil/init.luau"
            }
        }
    ],
    "name": "playerPolicyInfoUtil",
    "desc": " \n\nA very simple utility module for retrieving a player's policy info safely.\n \n```lua\nplayerPolicyInfoUtil.playerPolicyInfoPromise(localPlayer):andThen(function(playerPolicyInfo)\n    print(playerPolicyInfo.ArePaidRandomItemsRestricted)\n    print(playerPolicyInfo.AllowedExternalLinkReferences)\n    print(playerPolicyInfo.IsPaidItemTradingAllowed)\n    print(playerPolicyInfo.IsSubjectToChinaPolicies)\nend):catch(function(defaultPlayerPolicyInfo, errorMessage)\n    warn(string.format(\"Error retrieving player policy info because %s\", errorMessage))\nend)    \n```",
    "source": {
        "line": 17,
        "path": "src/playerPolicyInfoUtil/init.luau"
    }
}