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

Attempt to index local plr (a nil value)?

Asked by 5 years ago

Hello, I am getting these random errors (The one in the title.), I have dug through it and tried to figure out my issue, but I just cant fix it, anyways here is the code, thanks!

-SupremeStarfish local plr = game.Players.LocalPlayer local reward = 25 local winreward = 1 local DisplayStatus = game.ReplicatedStorage:WaitForChild("Status") local leaderstats = plr.leaderstats << This is where the nil happened I already made a leaderstats inside the player in a different script.

script.Parent.Touched:Connect(function() DisplayStatus.Value = plr.Name.." has won!" leaderstats.Points.Value = leaderstats.Points.Value + reward leaderstats.Wins.Value = leaderstats.Wins.Value + winreward end)

0
enter leaderstats into starterplayer smash_abIe 19 — 5y
0
okay, do you have an example? SupremeStarfish 21 — 5y
0
In the leaderstats variable, do plr:WaitForChild("leaderstats") KBsully1 0 — 5y
0
*Facepalm greatneil80 2647 — 5y
0
Thank you everyone for participating! I now have the bug fixed, the main problem was i was using a regular script! AAGH! But anyways thank you all again for helping. SupremeStarfish 21 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I wonder.. What type of script did you enter:

local plr = game.Players.LocalPlayer

?

If this is a localscript then, alright, but if it is a server-sided script, then this won't work. ^^

The error is telling us that the variable "plr" is nil, or in other words: does not exist.

Good luck with the further development!

Waterfoox

0
Congrats on being the only correct person to answer this question. DeceptiveCaster 3761 — 5y
Ad

Answer this question