You say the plants are leaning? Is there a light source that they are leaning toward? Also, how many watts is the bulb you have now?

Fungus gnats are probably not the reason your plants died, however fungus gnats thrive in overwatered soil. Maybe you watered them too much?