Hello everyone. I have 3 Values: Wood, Stone And Levels.
The datastore script is saving Wood but not Stone and Levels.
here is my code:\
local dataStore = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrid = "id_"..plr.UserId
local save1 = plr.leaderstats.Wood
local save2 = plr.leaderstats.Stone
local save3 = plr.leaderstats.Level
local GetSaved = dataStore:GetAsync(plrid)
if GetSaved then
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
save3.Value = GetSaved[3]
else
local NumberForSaving = {save1.Value, save2.Value, save3.Value}
dataStore:GetAsync(plr,NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
dataStore:SetAsync("id_"..plr.UserId, {plr.leaderstats.Wood.Value, plr.leaderstats.Stone.Value, plr.leaderstats.Level.Value})
end)