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

I have this script to say "Hello there PLAYERNAME." but can't get it to work? [closed]

Asked by 10 years ago

textButton = script.Parent textButton.MouseButton1Down:connect(function() print "Hello there"..username.."." end)

0
It's best if you enter code in a Lua Block. coo1o 227 — 10y
0
Sorry man! I mistaken-ed your Question for another! I'm so sorry! I feel so bad! D: TheeDeathCaster 2368 — 10y

Marked as Duplicate by TheeDeathCaster and Perci1

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
coo1o 227 Moderation Voter
10 years ago

Simple, you just need to get the player's name.

Since this is a text button (A GuiObject), it's best if you use a LocalScript.

IF you use a LocalScript, you can just get the username like so:

local username = game.Players.LocalPlayer.Name

LocalPlayer is a 'local property' of the Players service. It can ONLY be accessed by LocalScripts and it returns the Player object the LocalScript is running on.

Name is a property of every instance in the Roblox API. It is, simply, the name of the Instance. Player objects are always named after their player's username, so it can be used to get a player's username. Simple.

~coo1o

Ad