Connection:Disconnect() not working

I have this pretty simple script which is supposed to disconnect the connections it makes, but it is really inconsistent and doesn’t disconnect them most of the time.

		local Player = MainFrame:GetPlayer()
		local Tool = script:FindFirstAncestorOfClass("Tool")
		local Mouse = Player:GetMouse()
		local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")
		local debounce = false
		local holding = false

		local auto = true
		
		local Connections: {[number]: RBXScriptConnection} = setmetatable({}, {__mode = "kv"})
		
		local MouseConnections: {[number]: RBXScriptConnection} = setmetatable({}, {__mode = "kv"})
		
		table.insert(Connections, 
			Tool.Equipped:Connect(function()
				print("equipped", MouseConnections)
				holding = false
				table.insert(MouseConnections, 
					Mouse.Button1Down:Connect(function()
						print("down")
						holding = true
						while holding do
							if debounce then break end
							debounce = true
							warn(debounce)
							RemoteEvent:FireServer()
							task.wait(1/40)
							debounce = false
							if not auto then break end
						end
					end)
				)

				table.insert(MouseConnections,
					Mouse.Button1Up:Connect(function()
						print("up")
						holding = false
					end)
				)
				print(MouseConnections)
			end)
		)
		
		table.insert(Connections, 
			Tool.Unequipped:Connect(function() --// ** the part that disconnects stuff (doesn't really work)
				print("unequipped", MouseConnections)
				for i, Connection in pairs(MouseConnections) do
					print(Connection)
					Connection:Disconnect()
					print(Connection.Connected)
					Connection = nil
					MouseConnections[i] = nil
				end
				--table.clear(MouseConnections)
				print(MouseConnections)
			end)
		)
		
		table.insert(Connections, 
			Tool.Destroying:Connect(function()
				task.spawn(function()
					for i, Connection in pairs(Connections) do
						print(Connection)
						Connection:Disconnect()
						Connection = nil
						Connections[i] = nil
					end
					
					table.clear(MouseConnections)
					table.clear(Connections)
					
					MouseConnections = nil
					Connections = nil

					Player, Tool, Mouse, RemoteEvent, debounce, holding = nil, nil, nil, nil, nil, nil
				end)
			end)
		)

Even when I unequip the item, it continues to function in the background as if nothing happened.

This is what unequipping the item should always output:
image

This is what is outputted most of the time:
image

I’ve been trying to debug this for the past hour (my entire output gets bombarded with information every time I interact with the item lol), and still have 0 clue on how to fix this issue.
Anything?

There is no need to store connections made from the tool (eg Tool.Equipped, Tool.Unequipped) since when destroyed all connections to an instance are disconnected. Also there is no need to set everything to nil at the end since when the tool is destroyed so is all its ancestors meaning the script and its environment too.

In fact you’re overmanaging your memory usage, there is no need to disconnect any of these events since when the script is destroyed all the conenctions are disconnected and destroyed anyway. Since if this wasn’t the case there would be memory leaks all over roblox