Game.Player.PlayerAdded and then get the player which is provided in the () and do local PlayerName = plr.Name and then change the texxt of the username.
Or something which could be quicker and more effient is if u just want the player to see it u could just do in a local script find the local player and then do player.Name like what @exp_lol123 gave on the UI.
(if it is a diffrent text label tfor the username then u could just do Player.Name then doing what @exp_lol123 and puting it inside the string with the rest of the stuff.
Uhh using the PlayerAdded event within a server script (or just a Script) it would be changed for everyone, if you didn’t go over the gui of just one player. Anyway, I would recommend to just do something like this:
local player = game:GetService("Players").LocalPlayer
GUIElement.Text = "" .. player.Name -- this will do the text and the name.
This is for when you touch a part the text appears:
local part = *Your Part here*
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.PlayerGui.Your Gui Name here.TextLabel.Visible = true
player.PlayerGui.Your Gui Name here.TextLabel.Text = "Hi "..player.Name.." welcome to North Valley Academy"
end
end)
and for joining a game:
game.Players.PlayerAdded:Connect(function(player)
player.PlayerGui.Your Gui Name here.TextLabel.Visible = true
player.PlayerGui.Your Gui Name here.TextLabel.Text = "Hi "..player.Name.." Welcome to North Valley Academy"
end
end)
Hi everyone, thanks for all the suggestions. Either way, I have tried them all and can’t seem to get the to work even when fixing the location for the script to find the label. Is it something to do with text label settings? Should the text label be empty or have some sort of place holder there?
local player = game:GetService("Players")
local txt = script.Parent.Welcome
txt.Text = string.gsub(txt, "USERNAME", player.Name) -- You could set the text to "Hi, USERNAME"