Praise be to Allaah.
You do not have to obey them in disobeying Allaah or in anything that will adversely affect you, because the Prophet (peace and blessings of Allaah be upon him) said, “Obedience is only with regard to what is right and proper,” and “There is no obedience to any created being if it involves disobedience towards the Creator.” The person who tells you not to be friends with good people is not to be obeyed, whether they are your parents or anyone else. You should not obey anyone who tells you to be friends with bad people either. But you should speak to your parents in a good manner and in a way that is better, such as saying “These are good people, I benefit a lot from them, I am fond of them and I am learning a lot from them.” You should respond to them with kind words and good manners, and not be harsh with them. If they tell you not to be friends with them, do not tell them that you are seeking out good people and getting in touch with them, or that you have gone places with them if they do not approve of that. You only have to obey them with regard to acts of worship and what is good and proper.
If they tell you to make friends with bad people, or they tell you to smoke or drink alcohol or commit adultery, or other sins, then do not obey them or anyone else who tells you to do such things, because of the two hadeeth quoted above. And Allaah is the Source of strength.