Can i replace an old transistor with a pn2222?
Replacing one transistor with another depends on the application and the specs. If its working as a simple power switch for some leds, its easier than if its being used as a signal amplifier in a sensitive radio component or a voltage follower setup.
If its a simple power switch then look for the hfe or gain, the base emitter forward voltage drop, the max voltage and currents involved. You may need to adjust a base resistor or deal with differences in heat management.