I was telling my friend about the Papal infallibility and i was telling him about how the Holy Spirit is speaking through the Pope....Well, first of all, you need to refine your terminology here. Infallibility does not mean that the Holy Spirit "speaks through" the pope, like the Holy Spirit did with the authors of the Bible. That is called inspiration. Infallibility is a passive act of the Holy Spirit in which He ensures that what the pope says is true, not by actively giving him the true words, but by ensuring that whatever conclusions the pope draws with his own human abilities will be protected from error.
....and then he asked me how the Holy Spirit guides the Cardinals when they are selecting a new Pope. I wasnt really sure how to answer this for him since its hard for me to explain many things since he is a Muslim and so definitions are a lil different. Your help on this topic would be greatly appreciated.I think we find an excellent example of this in how the apostles chose the successor of Judas (cf. Acts 1:15-26). The apostles came together as a group, prayed to the Holy Spirit that He would guide them to make the right decision, and then the successor was chosen.
Note however that it is possible that a group of cardinals, who's hearts are not open to the promptings of the Spirit, may not choose the best man for the job. In the past, men have been chosen to succeed Peter who have caused much scandal to the faithful. But, we can still rest easy knowing that the perfect doctrine of the Church will never be corrupted. One way the Church remains holy is through the gift of infallibility, even though she be comprised of both saints and sinners.
For the particulars regarding the election of a pope, go here.