Entering a new environment can be scary and result in you feeling lonely; some of us aren't as outgoing as others and won't easily cure that loneliness by making friends. I'm not going to tell you that being nice and outgoing will give you all the friends you desire because every situation is different and some people just aren't meant to be your friends. Instead, I'll warn you of some sure-fire ways to eliminate the possibility of you making good friends.
1. Purposefully isolate yourself.
Keeping yourself cooped up even if it's to stay focused on work or school is keeping you away from any new experiences and people. A familiar isolated environment keeps you from growing and engaging with the world.
2. Lie
Building friendships can be like building bridges; if your foundation sucks, it won't last. If you try to deceive people about your interests to try and relate to others, you repress aspects of yourself while around them. Similarly, if you base a friendship completely off lies, the friendship then becomes about keeping those lies secret instead of enjoying each other's company.
3. Accept anyone as a friend
It's good to be open to making different types of friends, but not everyone is your friend. If you think that people who just tolerate being around you or only want you around so they can use/abuse you are your friends, then you are allowing your desperation to threaten your wellness.