I know that getting a Player's username in a local script is easy, BUT I'm running a function that needs to be ran in a script. How would I get their name?
Current script I have:
local PlayerId = game.Players:GetPlayerByUserId() -- Trying to get their Id local PlayerName = game.Players:GetUserIdFromNameAsync() print(PlayerId) print(PlayerName)
This is an example of how I would think of using it but it doesn't seem to work
You could use a PlayerAdded
function which will fire every time a player joins the game. You can set an argument of the player and just get their userId & name from there. Example:
game.Players.PlayerAdded:Connect(function(player) print(player.UserId) print(player.Name) end)