How to get a player via there name?

So I want to be able to get a player via there name. I dont mean like going into player service and getting them there, like idk how to explain it but heres a plugin that does it.

I basically want to get the player via there name basically how players:GetPlayerByUserId() works.

The plugin that does it:


Screenshot 2023-12-17 195052

2 Likes

Like, get an image of how they look like based on their name?

1 Like

Well I actually just want to get their ID

1 Like

Use :GetUserIdFromNameAsync.

Code:

local Players = game:GetService("Players")
local userId = Players:GetUserIdFromNameAsync("FroDev1002")
2 Likes

player.UserIdβ€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž

But what if they arent in the game, that doesnt work. Thanks though

Inside a localscript which I’ve put inside a textbox:

local Players = game:GetService("Players")
script.Parent.FocusLost:Connect(function() --When a player finishes typing player name
	local userId = Players:GetUserIdFromNameAsync(script.Parent.Text)
	print(userId)
end)

Oh, I didnt read the question correct sorry :sweat_smile: Maybe this can help: UserService | Documentation - Roblox Creator Hub

Edit: Whoops it’s already solved

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.