Raspberry Pi Mosfet Switch
In order to turn on the MOSFET, a certain voltage between its gate and source must be attained. In your case, you have an n-channel MOSFET, meaning that once the gate is driven to a higher voltage than the source, it will begin to conduct current between its source and drain.1

In order to do this the 12V circuit must not float with respect to the control circuit. You'll need the 12V circuit to share a ground with the Raspberry Pi in this case:



1 There's also a parasitic diode that allows conduction in the other direction regardless of gate voltage, but it's not relevant to this circuit as it is currently designed.