Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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?

0
I've edited my response Tyler090130 619 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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!

0
Should of said its not a local script my bad KronxGoat 50 — 5y
0
I've edited my response Tyler090130 619 — 5y
0
it ends up not working with multiple labels KronxGoat 50 — 5y
0
even thought the scripts in all of them KronxGoat 50 — 5y
View all comments (2 more)
0
This script is only supposed to work with one TextLabel. Tyler090130 619 — 5y
0
Is their a way to make it work for multiple? KronxGoat 50 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
while wait() do
    script.Parent.Text = ""..game.Players.LocalPlayer.Name
end
0
put a local script under the text label Alibolly 10 — 5y

Answer this question