I'm installing a bathroom fan and I can't get it to power on. I want to wire it to the switch that controls the lights in the bathroom. The power comes from the lights to the switch. After splicing everything together in the attic the fan won't turn on but the light does. When I disconnect the fan the light turns off but when I connect it it turns on. The fan has a connector that plugs into the fan. That fan motor has a wall plug. I confirmed that fan works but getting an extension cord and plugging it to the wall and to the fan. I removed the splice from switch and connected just the fan and light together and confirmed there was voltage. The light turns on but still no fan. I don't know what to do. Would it be simpler to run a separate switch for the fan?
OK, it looks like you wired the fan in series with the lights. Disconnect the fan. Get the lights to works like they did before. Then, after turning off the power, disconnect the two wires leading to the lights. Connect the wires from the fan to the wires from the lights, white to white, and black to black if in the USA. Then connect those two sets to the two wires that originally fed just the lights.