Hi guys! Any ideas why this doesn't save when the player leaves? I have an OnClose event to keep the game open for another 4 seconds which should be enough to save the data and it doesn't :/
Any help would be appreciated! Thanks :)
I get no errors in the output.
for _, child in pairs(modelSeven:GetChildren()) do for _, saved in pairs(utility:JSONDecode(tab)) do if rawequal(saved.Name, child.Name) then child.Value = saved.Value end end game.Players.PlayerRemoving:connect(function(plr) local tab = {} for _, v in pairs(child.Parent:GetChildren()) do tab[#tab + 1] = {Name = v.Name, Value = v.Value} end local encoded = utility:JSONEncode(tab) dataStore:SetAsync(plr.userId, encoded) end) end game.OnClose = function() wait(4) end