Choose your transportation. There are three ways to get to St. Andrews: taxi, bus and train. Taxi is the most expensive and the most direct; bus takes the longest but is cheapest, and train requires an additional taxi ride. If you have a lot of luggage and can afford it, opt for a taxi. If you have the time and fancy seeing the countryside, take the bus. Otherwise, take the train.
Get on the bus. If you are arriving from the airport, the Airlink 100 (a giant blue bus) can take you into the city center. It will drop you off directly in front of the train station, and from there St. Andrews Square is a few blocks away, down Princes' Street and onto St. Andrews Street.
The bus you are looking for is the x60, operated by Stagecoach Buslines, and the schedule is available at its website. Hop on there, and you'll be treated to a lovely trip across the countryside. It's a two-hour ride, and drops you off right in the heart of town.
Take the train. If you are arriving from the airport, you can take the Airlink 100 bus to the Princes' Street bridge, which will put you directly in front of the train station. Go down the ramp (very steep, be careful with heavy luggage!) and check the schedules for the next train to Leuchars. The town, about 10 minutes outside of St Andrews, is the closest train stop. The train will take one hour. The additional taxi ride is 10 minutes, and taxis are always available; you might have to wait for a bus.
Or splurge and take a taxicab. It's the quickest route at about 45 minutes straight from the airport, or one hour from the city center. The taxi, of course, will drop you off whereever you need to go. As a tourist, if you're looking for a place to start, go for the Cathedral. No better place to start the St. Andrews experience.