How to use auto focusing on d90?

I bought a 1.8f 50mm af Nikon lense and I can't get it to.autofocus, even.though I have the switch set to auto focus on the actual.camera

You need to be more specific which lens you have. Is it AF or AF-S? Perhaps a really old version which is something else? If it's an AF-S, be sure the switch on the side of the lens is set to AF mode.
A important question: does your camera autofocus with other lenses?

Your D90 can use any of the Nikkor AF, AF-I or AF-S lenses.
If your lens is a manual focus lens, then you will need to use the electronic rangefinder in the cameras viewfinder.
Look on page 229 of your user manual for a fuller explanation.

If other lenses autofocuses with your D90, the 50mm is broken.