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

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

Asked by 5 years ago

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.

0
xD Robloxian_Hero1234 14 — 5y
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 TheeDeathCaster 2368 — 5y
0
I did that but the text doesn't change. Is it because I'm on studio or is it something with the script? DankterPepper 18 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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
`..` is concatenation. https://www.lua.org/pil/3.4.html TheeDeathCaster 2368 — 5y
Ad

Answer this question