In this code, I pasted it on script but it doesn’t working.
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
15:52:47.489 - PolicyService error: Argument 1 missing or nil
Hello, it seems like player argument passed from PolicyService:GetPolicyInfoForPlayerAsync(player) is a nil value.
However, I tested your code without editing it, and it seemed to be working fine. Would you tell me where and when does the script runs? A screenshot of explorer might be useful though.
You might want to make this code work in LocalScript since you are using Players.LocalPlayer.
I suggest you to putting this code in LocalScript, inside StarterPlayerScript of game.StarterPlayer.
If you want to make this code work in server-sided script, you should not use Players.LocalPlayer since it’s only defined in LocalScript.