If you meet a stranger you may find them nice or find them bad. Regardless, you need to get to know them in a safe way before you trust them.
A stranger who is bad could for example kidnap you. When other people are around, they can help you, so it is always better not to be alone, but stay with friends or family when you are out and about. That is if you meet someone in the street.
If you are on the internet, on the other hand, for example playing a game, and someone unknown texts you, you should not respond to them. Or, most importantly, you should not give them ANY information about your personal life, such as your real name, school, address or phone number.