Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(a nil value) i need help to fix a plr value?

Asked by
iDevity -2
7 years ago

Workspace.H1C1.BLUE.SurfaceGui.TextButton.Script:4: attempt to index upvalue 'plr' (a nil value)

I need help to fix this, its says a nil value when i put local plr = game.Players.LocalPlayer

0
r iDevity -2 — 7y
0
BOII greatneil80 2647 — 7y

1 answer

Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
7 years ago
Edited 7 years ago

Note that you can only use game.Players.LocalPlayer in a LocalScript. You are using a normal script so that is why it won't work :)

http://wiki.roblox.com/index.php?title=API:Class/Players/LocalPlayer

If you have a event that listens to a click on the textbutton, you will need to do the following:

script.Parent.MouseButton1Click:connect(function(player)
    --code
end)

The 'player' will become the player who clicked it as that is a standard value that gets sent throug h at the event MouseButton1Click.

http://wiki.roblox.com/index.php?title=API:Class/GuiButton/MouseButton1Click

0
Yeah, iDevity should have read my bio. hiimgoodpack 2009 — 7y
0
:Connect() PyccknnXakep 1225 — 7y
Ad

Answer this question