Turn off the breaker supply electricity to the roof fan on the main electrical panel. Never work on an electrical appliance with power still flowing to it. Put down a drop cloth to catch any dust that may fall when going into the attic/roof. Situate a ladder under the roof fan.
Put on eye protection and climb the ladder. Remove the vent by unscrewing the mounting screws on the edges of the vent. Pull the vent away carefully, as debris and dust may fall from the opening as the vent is pulled away. Hand the vent to someone helping you or climb off the ladder and place it on the floor. Do not try to balance the vent on the ladder while you are working on the fan; it may fall and damage the floor or hit a pet or child.
Locate the motor and remove the wiring. In some cases, it is simply a single plug; in other cases, electrical wires run to the motor. Use a pair of pliers to remove the electrical wiring if it does not simply unplug from the connection. Be careful not to pull too hard with your hand or pliers, as you could damage or break the wires.
Unfasten the fan motor from the motor mount with a wrench or screwdriver. On some roof vents, the motor is secured by bolts, on others, by screws. Loosen each bolt or screw but do not completely unfasten them. Rather, make the bolts or screws loose enough to turn by hand. Hold the fan motor with one hand and then unfasten the bolts with the other. Do not situate your head directly under the fan motor; it could slip from your hands and strike you in the head. Hand the fan motor off to someone or climb off the ladder and place it on the floor.
Install the new fan motor. Align the new roof fan motor with the mounting holes and insert the bolts or screws into the motor mount. Tighten the bolts or screws with a wrench or screw gun. Tighten firmly against the mount to prevent vibrating or shaking. Reattach the wires by hand. Turn the breaker back on and then turn the fan on to test it. Replace the vent.