Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Check if a players age is over 13?

I know there is Player GetUnder13 but I cannot use that...

Does anyone know how a game can check if user is under or over 13?

2 answers

✓ Accepted answer

It is possible to check if the player is 13+ with a neat trick: use FilterStringForPlayerAsync!

According to the wiki article for FilterStringForPlayerAsync:

Filters a string appropriate to the given player's age settings, so they see what is appropriate to them. This function will only work if called from a Script on the server. If called on a client it will fail.

After testing this with several "naughty words" on two different accounts (my account, which is 13+, and a dummy account that is <13, I came up with several words that get filtered differently between the two, the most benign of which is suck.

On a 13+ account:

> print(game:GetService("Chat"):FilterStringForPlayerAsync("suck", player))
suck

On a <13 account:

> print(game:GetService("Chat"):FilterStringForPlayerAsync("suck", player))
####

Now all we have to check if the filtered string contains #'s. For that, we can use string.match. string.match returns nil if it can't find a matching substring. eg:

> print(("suck"):match("#"))
nil
> print(("####"):match("#"))
#

Wrap this in a function, make it return true if string.match returns something and false otherwise, and you've got a re-implementation of GetUnder13!

function GetUnder13(player)
	return (game:GetService("Chat"):FilterStringForPlayerAsync("suck", player)):match("#") and true or false
end

Tested, and this should return false for a 13+ account and true for a <13 account.

1 comment

0

Oh, and test this in a real Roblox server from a server-side script, otherwise FilterStringForPlayerAsync will not work.

This is not possible, you can only get the in-game age of a player, This is only the account age . You can't get the age of a roblox player due to security reasons

2 comments

0

then i will make my game ask for username and password and then make an api request to view age huehuehue

2

Let the flagging for potentially malicious script begin. You can not request users to provide a username and password. That is against ROBLOX's Terms of Service. Anyways, people can lie about their age it's not that hard.

This discussion is preserved as it was. New answers, comments, and votes are closed.