How do I gain respect?

I feel like once someone gets to know me they don’t respect me.. idk if I come off insecure, needy? Or just tell them too much about myself or what but I feel like once they start to get to know me they think they can act anyway towards me & my response in return is to act crazy & get crazy with my mouth.. but I don’t wanna be like that. So how do I keep myself respected?