it prints that data is saved, loaded etc but when it comes to actually loading the data it doesn't seem to function properly. no error is given
local dataStore = game:GetService("DataStoreService"):GetDataStore("Test3")
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local kills = Instance.new("IntValue")
kills.Name = "Eliminations"
kills.Value = 0
kills.Parent = stats
local deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Value = 0
deaths.Parent = stats
local careerKills = Instance.new("IntValue")
careerKills.Name = "Career Eliminations"
careerKills.Parent = stats
local careerDeaths = Instance.new("IntValue")
careerDeaths.Name = "Career Deaths"
careerDeaths.Parent = stats
local careerWins = Instance.new("IntValue")
careerWins.Name = "Career Wins"
careerWins.Parent = stats
local careerLosses = Instance.new("IntValue")
careerLosses.Name = "Career Losses"
careerLosses.Parent = stats
local credits = Instance.new("IntValue")
credits.Name = "Credits"
credits.Parent = stats
local ID = "SAVE-"..player.UserId
local saves = {careerKills.Value,careerDeaths.Value,careerWins.Value,careerLosses.Value,credits.Value}
local savedData = nil
pcall(function()
savedData = dataStore:GetAsync(ID,saves)
end)
if savedData == nil then
careerWins.Value = 0
careerLosses.Value = 0
careerKills.Value = 0
careerDeaths.Value = 0
credits.Value = 500
print("New Player")
else
careerKills.Value = savedData[1]
careerDeaths.Value = savedData[2]
careerWins.Value = savedData[3]
careerLosses.Value = savedData[4]
credits.Value = savedData[5]
print("Data Loaded")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local ID = "SAVE-"..player.UserId
local careerKills = player.leaderstats["Career Eliminations"]
local careerDeaths = player.leaderstats["Career Deaths"]
local careerWins = player.leaderstats["Career Wins"]
local careerLosses = player.leaderstats["Career Losses"]
local credits = player.leaderstats["Credits"]
local saves = {careerKills.Value,careerDeaths.Value,careerWins.Value,careerLosses.Value,credits.Value}
pcall(function()
dataStore:SetAsync(ID,saves)
print("Saved")
end)
end)
game:BindToClose(function()
for i,player in pairs(game.Players:GetPlayers()) do
if player then
player:Kick("Shutting Down")
end
end
wait(5)
end)
local function AutoSave()
while true do
local ID = "SAVES-"..Player.UserId
local saves = {careerKills.Value,careerDeaths.Value,careerWins.Value,careerLoses.Value,credits.Value}
dataStore:SetAsync(ID,saves)
print("Auto Save")
wait(60)
end
end

3 comments
yup this works perfectly, also am aware that only 4 show up just needed to put the values somewhere that i could see them to test
That's understandable.
I'm not sure why only four values show. Was it like that before?