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

why is there an erroe here i saw hedevking video and not coming?

Asked by 3 years ago

local DataStoreService = game:GetService("DataStoreService") local MyDataStore = DataStoreService:GetDataStore("MyDataStore")

game.Players.PlayerAdded:Connect(function(Player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = Player

local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Parent = leaderstats

local playerUserId = "Player_"..player.UserId

--load
local data
local succes, errormessage = pcall(function()
     data = MyDataStore:GetAsync(playerUserId)
end)

if succes then
    Points.Value = data
    --set our data to equal points

end

end) after the local playeruserid there is player.userid that player is in a blue line when i play it its saying this ServerScriptService.server script:13: attempt to index nil with 'UserId' - Server - server script:13

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

Answer:

wrong capitalization, should be Player not player (in your script line 13)


Some notes:

why is that called playerUserId, key will make more sense, but you dont need to change, it's working
it's thedevking not hedevking lol
0
"it's thedevking not hedevking lol" i completely agree Nozazxe 107 — 3y
0
thanks for answering and i have another doubt which you ca see ncihxad1123 12 — 3y
Ad

Answer this question