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

How to change text to text with player's name?

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.

3 comments

0

xD

1

You could get the player's name via the LocalPlayer of a LocalScript. Then, using concatenation, you set the TextLabel's text to something like TL.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/LocalPlayer

0

I did that but the text doesn't change. Is it because I'm on studio or is it something with the script?

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.