I found out that there are tons of people on the developer forum wondering how to make a game age restricted to only users over 13.
Now unfortunately, this cannot 100% detect if the player has faked their age on their account. But if they did not, this will kick them if they have safe chat.
Simply put this in ServerScriptService, and you are done! If the player is underage, they will be kicked.
local PolicyService = game:GetService("PolicyService")
local function CheckAge(player)
task.wait(1)
local playerPolicy
local sucess, policy = pcall(function()
playerPolicy = PolicyService:GetPolicyInfoForPlayerAsync(player)
end)
if not playerPolicy.AllowedExternalLinkReferences[1] and not playerPolicy.AllowedExternalLinkReferences[2] and not playerPolicy.AllowedExternalLinkReferences[3] and not playerPolicy.AllowedExternalLinkReferences[4] then
player:Kick("Player is under 13.")
end
end
game.Players.PlayerAdded:Connect(function(player)
CheckAge(player)
end)