The DataStore I made always saves but earlier today, it didn't. I'm super curious to figure out why but I couldn't think of anything. Can someone help me figure out why it would fail like that?
game.Players.PlayerRemoving:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore(player.UserId.."Save") local statstorage = player:FindFirstChild("Currency"):GetChildren() for i = 1, #statstorage do datastore:SetAsync(statstorage[i].Name, statstorage[i].Value) print("saved data number "..i) end print("Stats successfully saved") end) game.Players.PlayerAdded:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore(player.UserId.."Save") player:WaitForChild("Currency") wait(1) local stats = player:FindFirstChild("Currency"):GetChildren() for i = 1, #stats do stats[i].Value = datastore:GetAsync(stats[i].Name) print("stat numba "..i.." has been found") end end)
To be honest, I'd use google docs as a database, yes it uses web hooks and there's a limit but if you're game is a 24 or less players allowed this is perfect. https://devforum.roblox.com/t/using-google-spreadsheets-as-a-database/12658 -Its more organised, Its also great for receiving loss data.- I know it has nothing to do with your question, I just wanted to spread the word and seen as you was talking about database I thought I'd show.