How do I fix my alternating burning out headlights?

My headlight went out and the (pigtail/outlet) got fried. My friend replaced the bulb but not the over heated part. Since then the headlights alternate burning out. If we replace one, the opposite goes out. I'm sure i need to replace the (pigtail) part but is that causing the alternating issue? What's happening and how do I fix it?

crwdns2934089:0crwdne2934089:0 crwdns2934093:0crwdne2934093:0

crwdns2934109:0crwdne2934109:0

crwdns2889612:0crwdne2889612:0 0
crwdns2934285:0crwdne2934285:0