There are several issues with your code.
First off, I would recommend naming your variables something a little closer to what they equal. For example, your variable LocalPlayer_ is equal to a GUI Text Object. Consider possibly changing the variable name to something like 'TextLabel'. This is just to make it neater and make more sense.
Next, a BillboardGui will not work when inside a player - they would only work when inside the player's character, or some other part. If you're looking to have a GUI on the player's screen, consider using a ScreenGui instead. If you're wanting to use the BillboardGui, you'll need it to be inside the player's character. You can find the player's character by using,
local character = game.Players.LocalPlayer.Character
The If statement inside function display(player) is not needed. You already defined LocalPlayer_ as game.Players.LocalPlayer:WaitForChild("Billboard"):WaitForChild("Text"). So there would be no point in checking to see if the variable is still exactly as you previously defined it.
You can not use Text.Text because there was no variable created previous to this line named Text.
On that same line, you're attempting to set the text to "Welcome ".. player.LocalPlayer_
This would literally mean, that inside the player, you are trying to find game.Players.LocalPlayer:WaitForChild("Billboard"):WaitForChild("Text"). The game itself can not exist within the player, because the player exists within the game.
You are firing the function display(player) twice. Both with game.Players.PlayerAdded:connect(display) and with display(game.Players.LocalPlayer)
You are missing an end. You only have one end for the If statement. You need another for the actual function.
Also, I usually stray away from useing PlayerAdded in a LocalScript, because I usually run into issues with it when it's not Server-Side.
Below I will link some Wiki pages that I believe will help you:
PlayerAdded
Functions
Example code to learn from:
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local TextLabel = character:WaitForChild("Billboard"):WaitForChild("Text")
function display(player)
if TextLabel then
print("Success")
TextLabel.Text = "Welcome ".. player.Name
else
print("Error: 'Text' is not a member of 'Billboard'")
end
end
display(game.Players.LocalPlayer)
Though the above code will fully work, you need to study it, learn from it, and apply it. Do not just copy and paste, you won't learn that way and will make the same mistakes in the future. I hope this helps you.
If my answer has helped your or solved your problem, don't forget to upvote and confirm
1 comment
Line 06 - You never declared what the variable "Text" is