I’m trying to save tables using datastore for a Pokemon-type game. This is what I came up with, but for some reason it doesn’t save. No errors appeared in output. Any idea why? Any help is appreciated.
local datastoreService = game:GetService("DataStoreService") local leadKyatchiStore = datastoreService:GetDataStore("leadKyatchiStoreTEST") local caughtKyatchiStore = datastoreService:GetDataStore("caughtKyatchiTEST") local httpService = game:GetService("HttpService") function saveData(plr,stat,datastore) datastoreService:GetDataStore(datastore):SetAsync(plr,datastore) end game.Players.PlayerAdded:Connect(function(player) local Folder = Instance.new("Folder",player) Folder.Name = "playerData" local leadKyatchi = Instance.new("StringValue",Folder) leadKyatchi.Name = "leadKyatchi" local caughtKyatchi = Instance.new("Folder",player) caughtKyatchi.Name = "caughtKyatchi" local Data = caughtKyatchiStore:GetAsync(player.UserId) if Data then local tables = httpService:JSONDecode(Data) for name,value in ipairs(tables) do local stat = Instance.new("BoolValue",caughtKyatchi) stat.Name = name stat.Value = value end else print("Player is new. Start off as Natom.") end end) game.Players.PlayerRemoving:Connect(function(player) local datatosave = {} for i,v in ipairs(player.caughtKyatchi:GetChildren()) do datatosave[v.Name] = v.Value end caughtKyatchiStore:SetAsync(player.UserId,httpService:JSONEncode(datatosave)) end)