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

How would I find a PLAYERNAME?

Say I wanted to use a player's name in a script, but obviously won't know the name of them how would I do it? Would I have a variable that is equal to the player's name who touched the part?

1 answer

There are multiple ways of finding the player's name.

This script is a normal script:

script.Parent.Touched:connect(function(player)
print(player.Parent.Name) --This would print the name of the person who touched the brick
end)

For LocalScripts, its 1 line of code. game.Players.LocalPlayer.Name

eg (LocalScript)

print(game.Players.LocalPlayer.Name)
--> Output: Player's Name

I hope that I've answered your question :D

2 comments

0

Where would said local script go in the player?

0

What do you mean?

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