Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Anyone known how I could make a text label in a gui change to a players username in the gui?

I've been trying to find some things on this but it seems like theres nothing out there I really dont have any code for it but anyone have any tips or something on a devforum or something about this topic?

1 comment

0

I've edited my response

2 answers

✓ Accepted answer

This is actually quite simple. Here's how:

-- This is how you would do it in a LocalScript

local Player = game.Players.LocalPlayer -- Defining what the Player is 
local TextLabel = script.Parent -- Assuming you parented the script to a TextLabel

TextLabel.Text = Player.Name -- Changing the TextLabels Text to the Local Player's name




-- This is how you would do it in a Server Script

game.Players.PlayerAdded:Connect(function(player) -- defining the Player
	local TextLabel = script.Parent -- Change this to the path of the TextLabel
	TextLabel.Text = player.Name -- Changing the TextLabels Text to the Player's name
end)

Please accept this answer if this helps!

6 comments

0

Should of said its not a local script my bad

0

I've edited my response

0

it ends up not working with multiple labels

0

even thought the scripts in all of them

0

This script is only supposed to work with one TextLabel.

0

Is their a way to make it work for multiple?

while wait() do
	script.Parent.Text = ""..game.Players.LocalPlayer.Name
end

1 comment

0

put a local script under the text label

This discussion is preserved as it was. New answers, comments, and votes are closed.