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

A text in a sign wont show the username of the player looking at it How do i fix this?

I made a script in a sign with a textlabel and put the script in it containing this:

local name = game.Players.LocalPlayer.Name

script.Parent.Text = ("Thanks to "..name.." for playing the game!")

but I keep getting the error : Workspace.Spawn.Sign.Text.SurfaceGui.TextLabel.Script:1: attempt to index nil with 'Name'

1 comment

0

I put this in a regular script not a local script if anyone needs to know

1 answer

✓ Accepted answer

The problem is that you are not using a local script. LocalPlayer can only be accessed in a local script. You will have to go about this in another way. I'm not sure how you are going to choose whos name you want to display, but here is a script that will display the name of the most recent player to join:

game.Players.PlayerAdded:Connect(function(plr)
	script.Parent.Text = ("Thanks to ".. plr.Name.. " for playing the game!")
end)

Hope that helped, if you want it to work differently leave a comment and I'll see what I can do.

1 comment

0

thanks so much!

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