Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you get the name of the localPlayer?

local player = game:GetService("Players")
local Lplayer = tostring(player.LocalPlayer)
print(Lplayer)

It dosen't print out the LocalPlayer's username. Help please!

1 comment

0

You don't need tostring before the localPlayer; it is already a string value

3 answers

✓ Accepted answer

If this is via a Local Script, you can simply do

local player = game.Players.LocalPlayer
print(player.Name)

However if this is in a server script, I'm pretty sure you cannot do this. You can only get a player by using Events I believe. eg: A PlayerAdded event, etc.

local player = game.Players.LocalPlayer
print(player.Name)

2 comments

0

It doesn't work.

0

Im getting "Players.6zk8.PlayerGui.ScreenGui.TextLabel.Script:4: attempt to index nil with 'Name"'

wait(0.5)
local plr = game.Players.LocalPlayer
print(plr.Name)

This discussion is preserved as it was. New answers, comments, and votes are closed.