warn("Checking <13 or 13+ status..")
wait()
local id = math.random(9999,999999)
warn("Ticket id:"..id)
if game:GetService("PolicyService"):GetPolicyInfoForPlayerAsync().AllowedExternalLinkReferences == true then
print("User is 13+. Content unrestricted.")
else
print ("User is <13. Some content may be restricted.")
warn("This may be an error. If this is incorrect, HttpService is down. Contact us.")
end
Hi!
The error is as the title says.
What’s wrong?
Thanks!
GetPolicyInfoForPlayerAsync(game.Players.LocalPlayer) this works maybe
here
warn("Checking <13 or 13+ status..")
wait()
local id = math.random(9999,999999)
warn("Ticket id:"..id)
if game:GetService("PolicyService"):GetPolicyInfoForPlayerAsync(game.Players.LocalPlayer).AllowedExternalLinkReferences == true then
print("User is 13+. Content unrestricted.")
else
print ("User is <13. Some content may be restricted.")
warn("This may be an error. If this is incorrect, HttpService is down. Contact us.")
end
That would be the most recommended approach to ensure everything goes smoothly, think this would be the best approach
local PolicyService = game:GetService("PolicyService")
warn("Checking <13 or 13+ status..")
local id = math.random(9999,999999)
warn("Ticket id:"..id)
local success, info = pcall(PolicyService.GetPolicyInfoForPlayerAsync, PolicyService, game:GetService("Players").LocalPlayer)
if success then
if info.AllowedExternalLinkReferences then
print("User is 13+. Content unrestricted.")
else
print("User is <13. Some content may be restricted.")
end
else
warn(info)
end
If it says it should have error handling then give it error handling. It is making a web call which could fail for various reasons–the dev hub also explains why.
local PolicyService = game:GetService("PolicyService")
local Players = game:GetService("Players")
local Client = Players.LocalPlayer
local PolicySuccess, PolicyResponse = pcall(PolicyService.GetPolicyInfoForPlayerAsync, PolicyService, Client)
if PolicySuccess and PolicyResponse.AllowedExternalLinkReferences then
-- 13+
else
-- I would assume they are < 13 if the web call fails or if they're not allowed to see external.
-- or you could implement a system to retry the call.
end
If I had to assume, probably having a repeat until loop go on until the first return is true or the amount of retries have been exceeded, something like this
local PolicyService = game:GetService("PolicyService")
warn("Checking <13 or 13+ status..")
wait()
local id = math.random(9999,999999)
warn("Ticket id:"..id)
local success, info
local limit = 0
repeat
limit += 1
success, info = pcall(PolicyService.GetPolicyInfoForPlayerAsync, PolicyService, game:GetService("Players").LocalPlayer
until success or limit >= 3
if success then
if info.AllowedExternalLinkReferences then
print("User is 13+. Content unrestricted.")
else
print("User is <13. Some content may be restricted.")
end
else
warn(info)
end
Would repeat until it was successful or it has retried 3 times