How do you make it so a textlabel inside of a surfacegui has the players name?


How do I make it so a part has the players name on it.
Like on a surface gui then a textlabel?
Kind of like how GASA4 did it

(I know this is probably simple I’m just really confused.)

4 Likes

you can put a script under the textlabel and write:

local Character = script:FindFirstAncestorWhichIsA("Model")
if Character then
script.Parent.Text = Character.Name
end
2 Likes

i put the script under a text label and it didnt work

2 Likes

Are you using a server script and it is inside of the text label?
here is what it should look like

1 Like

yeah its a server script and inside of my startercharacter but the surface gui is inside a part also in the torso
do i remove the part?

can i see a image for reference?

is that part welded to the torso? otherwise it would fall straight off

yeah i welded it using moon animator and it didnt fall off

uhh, try putting it straight in the torso

wait actually, can i see inside your script, i copied the picture you sent and it still works for me


this is the script the one you sent me

and what does the text say when you play?

Server script inside of game.StarterPlayer.StarterCharacterScripts:

script.Parent:FindFirstChildWhichIsA('TextLabel').Text = script.Parent.Name

If you want to have multiple TextLabels, just use direct paths. If your character name is different from the player’s name, path to the player and use that name instead.

You’ll likely want to path to the TextLabel anyway using WaitForChild() in order to wait for it to exist in the first place.

Or if you want to be lazy:

local character = script.Parent
local textLabel

while not textLabel do
	textLabel = character:FindFirstChildWhichIsA('TextLabel')
end

textLabel.Text = character.Name
1 Like

i set the text in the properties hi
but when i play the game it remains hi meaning it probably doesnt work

Oh i didnt realize it was in starter character, i would use what @MightyDantheman wrote

No, you were right, I didn’t read correctly.

sorry for a kind of late response but it works thank you so much!!

Yeah, so it seems that scripts get removed from the StarterCharacter of which aren’t default scripts. Really weird behavior on Roblox’s part.

Dang I didn’t realize that, thanks for the help.

1 Like