Get a player object even if they are not in the game?

How can I get a player (an object that has properties) from a player name?
I know that I can use players:GetPlayerFromUserId(), but I was wondering if there is a similar method for a player name.

For example, getPlayer(“Winky_y”) would return with a player object with all my properties.

All help is greatly appreciated.

4 Likes

No there is no way to achieve this. it is impossible to get the player object from a name/user id if they are not in the server. Could you explain what you are trying to do? If you want the player’s character model you can use: Players | Documentation - Roblox Creator Hub

1 Like

GetPlayerFromCharacter, GetPlayerFromUserId, and all the other GetPlayers functions, only search for players that are currently in the Server. You can not get access to the player object, unless it is inside the Players service.

However, you can get certain properties of a Player and it’s character through other means. What are you trying to do exactly?

I am trying to make an unban function for an admin script.

What the script does it loads the player, changes the datastore for that player to an unbanned state, then saves the player’s new data.

When a player joins the game the script checks if they are banned through the datastore, and, if they are, kicks them with arguments provided.

@ExcessEnergy

Why would you need the player object? You would just need the user id? Using player names for banning is ineffective since they can change their names.

Because it is an admin script, ideally a user would be able to use the command “unban Winky_y” and have it work.

It is true, you only need the UserId. Just trying to up the user experience.

EDIT: Just stumbled across this (just before @cjjdawg posted… lol.) :
game.Players:GetUserIdFromNameAsync("Winky_y")

Thanks guys!

1 Like

You can use this method from the Players Service: Players | Documentation - Roblox Creator Hub, to find the UserId from the name, then add the UserId to the banned database.

6 Likes

Not sure why I thought that I needed the player object. Thanks for the help.

2 Likes