Why doesn't my data store script work?
Here it is:
DataStore = game:GetService("DataStoreService"):GetDataStore("PeasStore")
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"
local points = Instance.new("IntValue", stats)
points.Name = "Points"
local coins = Instance.new("IntValue", stats)
coins.Name = "Coins"
local key = ("player-" .. player.UserId)
local savedValues = DataStore:GetAsync(key)
if savedValues then
points.Value = savedValues[1]
coins.Value = savedValues[2]
else
local valuesToSave = (points.Value)
DataStore:SetAsync(key, valuesToSave)
end
end)
Error at line 19!

4 comments
im not sure if this will work but when it says points.Value = savedValues[1] make it points.Value = savedValues[1] or 0
Didn't work...
It's not recommended to use the 2nd arguement of Instance.new
I know. But do you have an answer to my question?