Player GUI text not updating when PlayerAdded is triggered

Issue Description:

I am experiencing an issue with the UserTitle.Text field within my GUI does not update correctly when a new player joins the game. The script is supposed to update the text to reflect the player’s name and UserId, but the text remains unchanged.

Reproduction Steps

  1. Create a GUI with a UserTitle TextLabel inside a UserIDOverlayScreen Frame within the PlayerGui.
  2. Use a LocalScript that listens for the PlayerAdded event and updates the UserTitle.Text to display the player’s name and UserId.
  3. When a new player joins, the text does not update as expected.
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local UserIDOverlayScreen = PlayerGui:WaitForChild("UserIDOverlayScreen")
local UserTitle = UserIDOverlayScreen:WaitForChild("UserTitle")

Players.PlayerAdded:Connect(function(player)
	UserTitle.Text = player.Name .. " (" .. player.UserId .. ")"
end)

Expected Behavior

When a new player joins, I expect the UserTitle.Text to update with the player’s name and UserId, e.g., PlayerName (12345678)

Visual Aids:

2 Likes

iirc playeradded isnt called on the client

2 Likes

I forgot to mention that I tried doing it with LocalPlayer.CharacterAdded too, and both remain giving me the text as “Label”…

2 Likes

Yeah because the character could have loaded before the event could have been called, so you need to also check if player.Character ~= nil then do whatever

2 Likes

Okay, I refined a bit of the script using a local function following up on this context and it worked

Bizarre that back in the day, it would’ve worked fine, but I believe that my brain went to an outdated moment and forgot that some features existed so the character loads faster :sweat_smile:

Well, thank you for telling me. I will mark this as a resolve so it can be closed

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.