Fixing a DataStore to make Players not lose information

Hello everyone, I am InquistorWasBanned and I have been making a game. I have a leaderstat that uses DataStore2, and it is really great because players do not lose information. But my saving inventory DataStore does not always save for some reason. How can I fix this?

local DataStore = game:GetService("DataStoreService"):GetDataStore("MyDataStore")

game.Players.PlayerAdded:Connect(function(plr)
	
	
	
	
	local data
	
	local success, errorMessage = pcall(function()
		data = DataStore:GetAsync(plr.UserId)
	end)
	if data ~= nil then
		for _, toolName in pairs(data) do
			
			local tool = game.ReplicatedStorage.Tools:FindFirstChild(toolName)
			
			if tool then
				local newTool = tool:Clone()
				newTool.Parent = plr.Backpack
				
				local newTool = tool:Clone()
				newTool.Parent = plr.StarterGear
				
			end
		end
	end	
end)
game.Players.PlayerRemoving:Connect(function(plr)
	
	local toolsTable = {}
	
	for _, tool in pairs(plr.Backpack:GetChildren()) do
		if game.ReplicatedStorage.Tools:FindFirstChild(tool.Name) then
			table.insert(toolsTable,tool.Name)
		end
	end
	
	
	local success, errorMessage = pcall(function()
		DataStore:SetAsync(plr.UserId,toolsTable)
	end)
	
end)

game:BindToClose(function()
	for _, plr in pairs(game.Players:GetPlayers()) do
			local toolsTable = {}
			
			for _, tool in pairs(plr.Backpack:GetChildren()) do
				if game.ReplicatedStorage.Tools:FindFirstChild(tool.Name) then
					table.insert(toolsTable,tool.Name)
				end
			end
			
			
			local success, errorMessage = pcall(function()
				DataStore:SetAsync(plr.UserId,toolsTable)
			end)	
		end
end)