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 4 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 — 4y

2 answers

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

Answer this question