RPi pin not controlling NPN transistor as expected
These are the basic ways of switching using either PNP / P channel MOSFET for high side switch or NPN / N channel MOSFET for a low side switch.
At all times the ground (0V) of the battery and the rpi are common.

Note: R5 (1k0) is optional but is a useful if using a Darlington NPN (high gain) as it helps to pull down any leakage current through the PNP.