Setting text in billboard GUI to players username

So basically I am trying to make a script that sets the text of ‘Title’ to the Players username and to be serversided.
image
I have this script here which I thought would work but does not:

while wait() do
script.Parent.Text = script.Parent.Parent.Parent.Parent.Parent.Name
end

Can anyone help me fix this?

1 Like

Any errors?
30 charssssssssssssss

No errors in the code and I have tried more ways but none of them worked.

Get rid of that loop, it’s not even needed.

Access the player the proper way instead:

local Players = game:GetService('Players')
local Player = Players.LocalPlayer

script.Parent.Text = Player.Name

I’ll try this out.
(30 chars.)

You cannot access LocalPlayer from ServerScripts

Otherwise, maybe put some script into ServerScriptService, listening to a PlayerAdded event, then listening to the CharacterAdded event, and cloning that UI with their proper name into the head.

Didn’t work.
(30 chars…)

Obviously not.
I assume this is UI-related, localscripts should be used to handle it.

EDIT:
I might see what you’re trying to do, hook up a PlayerAdded event instead.

local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(Player)
	script.Parent.Text = Player.Name
end)

Yes, but you want their names publicly displayed, also, in terms of UI it does not matter if Server or Client side, as their Tag is descendant of their character (which exists in the server side, and should be modified from there!!!).

Your code also will not work, because it is possible the character does not exist just after the player joins.

-- THIS SERVERSCRIPT INTO SERVERSCRIPTSERVICE!!!!!

local Players = game.Players

Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character) -- every time they spawn
        local UI = script.GUI:Clone -- PARENT YOUR BILLBOARD GUI INTO THE SCRIPT, SO IT GETS CLONED
        UI.Frame.Title.Text = Player.Name -- Set text to the player name
        UI.Parent = Character:WaitForChild("Head") -- Set parent of Ui to head
    end)
end)