local player = game:GetService("Players") local plr = player.LocalPlayer local GUI = game.StarterGui.ScreenGui.TextLabel player.PlayerAdded:Connect(function() GUI.Text = plr end)
When I put "" to the plr then it will change the text to plr. But when I remove the "" it will give me a bad argument error. So does anybody know how to change text to a variable? The plr variable means "RebornedSnoop" which is me but it doesnt change like a normal text. Sorry I cant explain very well. But please help if you understand. Thanks.
You can get the localplayers name using plr.Name
. Here's an example:
local player = game:GetService("Players") local plr = player.LocalPlayer local GUI = game.StarterGui.ScreenGui.TextLabel player.PlayerAdded:Connect(function() GUI.Text = plr.Name -- Name get's the local players name, that simple end)
Really simple, good luck with your game!
Put a LocalScript inside of the TextLabel and write this.
script.Parent.Text = game.Players.LocalPlayer.Name
You do not and cannot use game.Players.PlayerAdded in a LocalScript, since it runs on the client and not the server.
And if you're going to change any gui through a server, you have to use PlayerGui.
game.Players.PLAYER_NAME_HERE.PlayerGui.ScreenGui.Frame.TextLabel.Text
Try changing the StarterGui to PlayerGui
local player = game:GetService("Players") local plr = player.LocalPlayer local GUI = game.PlayerGui.ScreenGui.TextLabel player.PlayerAdded:Connect(function() GUI.Text = plr end)