Ad
Log in to vote
0

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

Asked by 3 days ago
Edited 3 days ago

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'

0
I put this in a regular script not a local script if anyone needs to know TheForgottenScript 2 — 3d

1 answer

Log in to vote
0
Answered by 3 days ago

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.

0
thanks so much! TheForgottenScript 2 — 3d
Ad

Answer this question