I'm currently trying to edit a TextLabel with a script. In the script, I'm trying to change the text of the label so that it is a certain line of text and then the name of the player. Example: "Welcome to the game, name of player!" I have no knowledge of how to do this so I need help on how to create the script.
COMMUNITY QUESTION
How to change text to text with player's name?
1 answer
put this into a local script and parent it to the textbox
script.Parent.Text = "Welcome to the game "..game.Players.LocalPlayer.Name
its that easy, the little .. means followed by and ofcourse the text in the speachmarks is the test you always want to be in there i wouldnt have given u the script if it wasnt this easy btw
1 comment
1
.. is concatenation. https://www.lua.org/pil/3.4.html
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
xD
You could get the player's name via the
LocalPlayerof a LocalScript. Then, using concatenation, you set the TextLabel's text to something likeTL.Text = 'Hello ' .. LocalPlayer.Name. As to getting the LocalPlayer, here's a link to the Dev Hub. https://developer.roblox.com/api-reference/property/Players/LocalPlayerI did that but the text doesn't change. Is it because I'm on studio or is it something with the script?