Look at all of your amounts of SetAsync()
, just store a dictionary instead of 7 keys. That is not all, the game is closing when the event is fired, and the game doesn’t give enough time for the PlayerRemoving event to finish, and the game shuts down too quickly. You would have to set up a function that runs when the game closes using game:BindToClose()
local saveData(plr)
... -- save a dictionary
end
game.Players.PlayerRemoving:Connect(saveData)
game:BindToClose(function()
for i, plr in ipairs(game.Players:GetPlayers() do
saveData(plr)
end
end)
More info can be found here