Workspace.Workspace:6: attempt to index a nil value
function script.UploadScore.OnServerInvoke(player) local inv = player:WaitForChild("leaderstats") local score = game:GetService("DataStoreService"):GetOrderedDataStore("TopScores") score:SetAsync(player.Name, inv:FindFirstChild("Points").Value) -- Line 6 end
This is the script. it's called Workspace for now. I don't know what part is a nil value
"Indexing a nil
value" occurs when you use .
or :
on a value that is nil
.
Looking at your code, inv
is definitely not nil
(because it was gotten using WaitForChild
, player
is definitely not nil
.
I believe that score
should never be nil
.
In this case, is probably accessing inv:FindFirstChild("Points")
. That is, there will be an error if inv
does not have a child named "Points".
To find out which part is the nil
value, of course, you should do debugging yourself, and print
out each of the values involved and make sure they are all predictable.