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

Attempt to index local plr (a nil value)?

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)

5 comments

0

enter leaderstats into starterplayer

0

okay, do you have an example?

0

In the leaderstats variable, do plr:WaitForChild("leaderstats")

0

*Facepalm

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.

1 answer

✓ Accepted answer

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

1 comment

0

Congrats on being the only correct person to answer this question.

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