Arduino stops working correctly as soon as a DC motor is connect

You are attempting to power the sensor from a digital output. What current does the sensor draw when powered?

And, looking at the code, if you do a stopmotor() after 60 seconds, and you aren't fully suppressing the transient that results, it's not surprising the Arduino resets. My guess is it's a combination of wiring, current return paths, etc. that's clobbering you.

yes the sensor is powered through the digital output put to be honest I'm not sure how much currents it draws and I dont have a multimeter to mesure it so I wont know until monday.

and how should I supress the transient that results, the only thing that I have is the 10k resistor to let the current flow from the MOSFET into ground so it doesnt act as a capacitor and leaves the motor on

Step 1, prove my theory. Reduce the period to 10000, run it again - do the resets happen every 10 seconds now?

I'll test it tomorrow since it is already late for me, but I'll keep you posted

No. The Arduino will take whatever current it need and no more.

Very little current that is not a problem

and how should I supress the transient that results

There is none.

Build everything on a solderless braedboard first.

If you are using a separate supply it cannot.
Read post #33

But the problem is that it is happening with a seperate power source (this is the terminal when in water and when dry)... And it is happening at an inconsistent rate...

Back in past #32 you said this

but I tried it again in water and it's running perfectly.

I assumed that meant you had no problems.
Are you now saying that the pump stops working?

No, what I said was correct, It works fine in water but as you pointed out it should work equally well outside water correct? and it isn't

I never said that!
I explicitly said several times that it must be in water or you will damage it

I misexplained myself I think, you indeed pointed several times that it should be in water to prevent damage but what I tried to say was that it should be working well outside water for small periods of time and during those it shouldn't affect the behavior of the arduino right? But it is....

No, even short periods can damage it.
If it is starting to heat up it may draw more current and cause more electrical interference and indeed affect the Arduino.

Without the resistance of water, the motor speed will be markedly higher. When you shut it off, I would then expect that the electrical transient induced at that time would be greater. How much? Got an oscilloscope? No? Then assume the worst, not the best.