Someone helped me with a DataStore that should automatically save and load and it appears to do nothing with no error.
Game.Players.PlayerRemoving:connect(function(Player1)
local key = "user_" .. Player1.userId
Game:GetService("DataStoreService"):GetDataStore("Stats"):UpdateAsync(key, function(oldValue)
local Data1 = Player1:WaitForChild("leaderstats"):GetChildren()
for i= 1,#Data1 do
Data1:SetAsync(Data1[i].Name, Data1[i].Value)
end
end)
end)
Game.Players.PlayerRemoving:connect(function(Player2)
local key = "user_"..Player2.userId
if Game:GetService("DataStoreService"):GetDataStore("Stats"):GetAsync(key) ~= nil then
local Data2 = Player2:WaitForChild("leaderstats"):GetChildren()
for i = 1, #Data2 do
Data2:GetAsync(Data2[i].Name)
end
end
end)

3 comments
Dude that's my answer from before, I can understand that you copy and pasted, q.q!
Ummm, i said someone helped me. (You). But it did not really work at all.
Well I notice a few mistakes so I can fix it , mk