Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I find a PLAYERNAME?

Asked by
Mystdar 352 Moderation Voter
10 years ago

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

Log in to vote
0
Answered by 10 years ago

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

0
Where would said local script go in the player? Mystdar 352 — 10y
0
What do you mean? fahmisack123 385 — 10y
Ad

Answer this question