Hey everyone, this is my first time using ordered data store. When I am trying to save the data, I get the Warn Data Couldn't be saved I don't know what im doing wrong?
local theStatsDataStore = game:GetService("DataStoreService"):GetOrderedDataStore("theStats")
game.Players.PlayerAdded:Connect(function(player)
local Exp = player:WaitForChild("theStats").Exp
local Levels = player:WaitForChild("theStats").Levels
local theData
local success, theError = pcall(function()
theData = theStatsDataStore:GetAsync(player.UserId)
end)
if success then
if theData ~= nil then
Exp.Value = theData[1]
Levels.Value = theData[2]
else
print("No Data")
end
else
warn("Data couldn't be loaded")
end
end)
-- save the data
game.Players.PlayerRemoving:Connect(function(player)
local tableToSave = {}
table.insert(tableToSave, player.theStats.Exp.Value)
table.insert(tableToSave, player.theStats.Levels.Value)
local success, theError = pcall(function()
theStatsDataStore:SetAsync(player.UserId, tableToSave)
end)
if success then
print("Data Succesfuly Saved!")
else
warn("Data couldn't be saved")
end
end)

2 comments
Not the one you set, but are you getting that?
I am only getting the one that i set, not the furthers requests will be dropped