Text wont change

Hello developers,
while making a UI, I tried changing it on join to my player name. Although, I did not have got it and my print did not fire so there is a error. Here is my code:

local Title = script:WaitForChild(script.Parent)
???

Do you mean:
local Title = script:WaitForChild(script.Parent.Name)
???

What is Title supposed to be?

You think it is the WaitForChild?

What’s with the script:WaitForChild(script.Parent)? Just do script.Parent.

You made a mistake: local plr = game.Players then put it in a parameter of the PlayerAdded function, which made it turn into an error because plr is game.Players (it is already defined, so function parameter basically gets plr variable: error), and it is not the Player who joined.

Instead. The script should be:

local Title = script:WaitForChild(script.Parent)
local plrs = game:GetService("Players")

plrs.PlayerAdded:Connect(function(plr)
    Title.Text = "Welcome, "..plr.Name
    wait(.2)
    print("Successfully changed Text to "..Title.Text)
end)

If the title variable doesn’t work then try:

local Title = script.Parent 

or

local Title = script:WaitForChild(script.Parent.Name)
1 Like