Issue with Updating Text Label in Roblox Game (Based on Players:GetNameFromUserIdAsync()

  1. What do you want to achieve?
    I want to update a text label in to display the username of the match host followed by “'s Lobby.”

  2. What is the issue?
    The text label (Lobby.HostText.Text) is being updated to “Roblox’s lobby” instead of the expected result (HostName .. "'s Lobby") so xProlific's Lobby even though Players:GetNameFromUserIdAsync(MatchHost) is returning the correct username, and the HostName variable is printing my name correctly. There is no other external scripts or any other lines of code that change the Text of the Header

  3. What solutions have you tried so far?

I have checked the initial value of Lobby.HostText.Text and confirmed that it’s not set to “Roblox’s lobby.” I’ve also added debugging print statements to verify the values of HostName. (They are all correct)

Images:
Result of print("HostName.. 's Lobby")
image

TextLabel:

Code:

local HostName = Players:GetNameFromUserIdAsync(MatchHost)
print(HostName .. "'s Lobby")
Lobby.HostText.Text = HostName .. "'s Lobby"
Lobby.Name = HostName
 local HostName = Players:GetNameFromUserIdAsync(MatchHost)
local LobbyText = HostName .. "'s Lobby"
print(LobbyText)

Lobby.HostText.Text = LobbyText

Lobby.Name = LobbyText

By storing the concatenated text in a separate variable (LobbyText ), you can both print it for debugging purposes and set the Lobby.HostText.Text property with the expected value.

Heyo! I’ve tried the code and here’s the output

Output: image
Frame Name image

Unfortunately, the text itself is still “Roblox’s Lobby”

It’s possible that the Lobby.HostText element isn’t being properly updated. Try this:

  • Verify that Lobby.HostText is indeed the correct text label element that you want to update. Make sure there are no other elements with similar names or that the element hasn’t been reset elsewhere in the code.

  • Ensure that Lobby.Name refers to the parent of Lobby.HostText and not another object. It should be the parent frame or object where you want to set the new text.

Try this debug print:

local HostName = Players:GetNameFromUserIdAsync(MatchHost)
local LobbyText = HostName .. "'s Lobby"

print("LobbyText:", LobbyText) -- Debug print

Lobby.HostText.Text = LobbyText

print("Lobby.HostText.Text:", Lobby.HostText.Text) -- Debug print

Lobby.Name = LobbyText

print("Lobby.Name:", Lobby.Name) -- Debug print
  • Verify that Lobby.HostText is indeed the correct text label element that you want to update. Make sure there are no other elements with similar names or that the element hasn’t been reset elsewhere in the code.

Yup I’ve verified it is indeed the correct text label element that I want to update. (I’ve checked the entire code multiple times)

  • Ensure that Lobby.Name refers to the parent of Lobby.HostText and not another object. It should be the parent frame or object where you want to set the new text.

Yes, “Lobby” is indeed the parent frame.
image

Output (I have added a second print statement for the text, and the lobby path too) :


Still updates to “Roblox’s Lobby” for some reason

Nevermind, I figured out the problem (I was editing the Lobby function, not the Party haha must’ve slipped. All good now :slight_smile:

1 Like

I’m glad you figured it out! I wish you luck in your game.

1 Like

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