How to get the UserID of a player thats offline from their UserName

Hey! I’m working on an admin script and right now I’m working on banning players. What I’m doing is when a player is InGame, if you say their username the game collects their UserID and places it in a DataStore.
Or if the player uses somebodies UserID that isnt in game then it also places their UserID in a datastore.
But a problem with this is that is most people wouldn’t be willing to get the players UserID to ban them.
I also cant use UserNames because if the player changes their name they can ban evade.
So, is there a way to get the players UserID from their UserName when their offline?

1 Like

Check out Players:GetUserIdFromNameAsync.

2 Likes

Thanks! I will definitely try using this.

1 Like

Can confirm this one is the correct answer ^^^