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

how do i get a script to display the local players name to a text box?

heres what i got no errors when i run it but it wont display!

local Players = game:GetService("Players") local player = Players.LocalPlayer function onPlayerAdded(players) script.Parent.Text = player.Name end

3 comments

0

What kind of gui are you using to display the name?

0

please use a code block.

0

also, are you running the function??

1 answer

If you want the LocalPlayers name in a TextBox, use the code below.

local TextBox = script.Parent
TextBox.Text = game.Players.LocalPlayer.Name

If you want the Text to change everytime a new player joins, use the code below.

local Players = game:GetService('Players')
local TextBox = script.Parent
Players.PlayerAdded:Connect(function(plr)
	TextBox.Text = plr.Name
end)

I wasn't completely sure what you wanted, giving the code you provided didn't make much sense. Both scripts I provided should work.

Also, make sure you're using a LocalScript when changing objects in StarterGui!

1 comment

0

3 answers ppl were faster than me writing in 3 minutes. just. wow. :/ jk

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