I know there’s a function that allow’s you to get a players character based of there username.
Example
local Player = Players:GetPlayer('HeWo30')
Player.Character -- // etc etc etc...
But I can’t find it anywhere.
I know there’s a function that allow’s you to get a players character based of there username.
Example
local Player = Players:GetPlayer('HeWo30')
Player.Character -- // etc etc etc...
But I can’t find it anywhere.
To get the character, you can simply do:
local Players = game:GetService("Players")
local Player = Players:FindFirstChild("Username")
if (Player ~= nil) then
local Character = Player.Character
end
This will only work if the player is in the game though
GetPlayerFromCharacter() or game:GetService(“Players”):FindFirstChild(Username)
???
GetPlayerFromCharacter()
This require’s the character.
Yeah I know, I messed up. but is the second suggestion the one you’re looking for?
I was planning on having something like
-- // Get player object from username
local Player = functionHere('Username')
Player.UserId
Player.Name
Player.DisplayName
function FunctionHere(Name): Player?
if Players:FindFirstChild(Name) then
return Players:FindFirstChild(Name) -- will return player object.
end
end
Like this?
This is highly redundant when you can just do local player = Players:FindFirstChild(username)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.