I've made multiple data stores before and this has never occurred. I'm making a new one rn and it gives me an error say "ServerScriptService.Saving:31: bad argument #3(string expected, got nil)". Is this even fixable?
game.Players.PlayerRemoving:Connect(function(player) local statstorage = game.ReplicatedStorage.PlayerData:FindFirstChild(player.UserId):GetChildren() for i = 1, #statstorage do local datastore = game:GetService("DataStoreService"):GetOrderedDataStore(statstorage[i].Name) datastore:SetAsync(player.UserId, statstorage[i].Value) end end) function Save(player) local statstorage = game.ReplicatedStorage.PlayerData:FindFirstChild(player.UserId):GetChildren() for i = 1, #statstorage do local datastore = game:GetService("DataStoreService"):GetOrderedDataStore(statstorage[i].Name) datastore:SetAsync(player.UserId, statstorage[i].Value) end end ------------------------------------------------------------------------------ game.Players.PlayerAdded:Connect(function(player) spawn(function() while true do wait(600) Save(player) end end) game.ReplicatedStorage.PlayerData:WaitForChild(player.UserId) wait(1) local stats = game.ReplicatedStorage.PlayerData:WaitForChild(player.UserId):GetChildren() for i = 1, #stats do local datastore = game:GetService("DataStoreService"):GetOrderedDataStore(stats[i].Name) stats[i].Value = datastore:GetAsync(player.UserId) end end)