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!
Because you're not actually saving it in a table, you're just saving the points' value by itself because you have normal parantheses, instead of curly parantheses used to construct a table.
local valuesToSave = {points.Value} DataStore:SetAsync(key, valuesToSave)