Controlling the speed of a dc motor?

I have 2n3904 transistors (if that matters) and everything else. Do I need to use a resistor before the transistor? How will it effect it?