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)
local datastore = game:GetService("DataStoreService"):GetDataStore("Stats") game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() wait(4) local p1 = player:FindFirstChild("leaderstats"):GetChildren() for i = 1, #p1 do datastore:SetAsync(p1[i].Name, p1[i].Value) end end)
Simply this will save a players data.
game.Players.PlayerAdded:connect(function(nplayer) nplayer:WaitForDataReady() wait(4) -- I added this on local p2 = newplayer:FindFirstChild("leaderstats"):GetChildren() for i = 1, #p2 do p2[i].Value = datastore:GetAsync(p2[i].Name) end end)
Hmm Try this, I mean this should work I made this one out of my game.
+1 if this worked and helped!!