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

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

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

✓ Accepted answer

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

2 comments

0

"it's thedevking not hedevking lol" i completely agree

0

thanks for answering and i have another doubt which you ca see

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