Click a GUI button to rotate an object

Greetings! I’m very much new to the whole scene of game creation, so please be gentle with me! I’ve been up all night trying to figure out a way to do what I need done, but I’ve literally gone square-eyed from it haha.

Essentially, I need help with a script in order to do the following:

-I have a ‘platform’ (which is essentially a flat base) that I want to have rotate in 45degree sections upon clicking on a 3d text object. I know how to make the 3d text clickable, but I don’t know if/how I can make it target the ‘platform’ when clicked on in order to rotate it.

-The idea is that there will be vehicles on the platform, and when you click the button the platform will rotate (or ‘spin’) to bring the next vehicle in to view (there will be 2 buttons, 1 for ‘next’ and 1 for ‘previous’ vehicle). I’d like to have the rotation happen quickly but smoothly.

This is what I’m currently using after trolling through what feels like a thousand other threads and Google searches looking for a solution. At the moment it’s set to a Horizontal key (A or D) as I couldn’t for the life figure out how to make it work on a OnMouseUp when clicking on a 3d text GUI object.

public class GUI_VehicleSelect : MonoBehaviour {

const float ROTATE_TIME = 1.0f; // seconds
const float WAIT_TIME = 1.0f; // seconds
const float ROTATION_MAX = 45.0f; // degrees
float timer = 0.0f;
void Update(){
		if (Input.GetButton ("Horizontal"))
    // increment timer
    timer += Time.deltaTime;
    // reset the timer after it goes past total time
    while (timer > ROTATE_TIME + WAIT_TIME)
        timer -= ROTATE_TIME + WAIT_TIME;
    // rotate the object
    if (timer < ROTATE_TIME) {
        gameObject.transform.Rotate(Vector3.up * Time.deltaTime * ROTATION_MAX / ROTATE_TIME);

This SORT OF does what I need it do do. It will rotate in the 45degree segments like I want and it does it smoothly, but it will only rotate in one direction and if I ever let go of either Horizontal button it stops. I need it to do the full 45degrees as soon as it is triggered (regardless of whether I let off either the A/D keys or the mouse) and be able to rotate clockwise or anticlockwise (depending on which button is pressed).

I think that’s all for now. I’ve always loved the idea of game creation and I’ve spent the last few days watching endless videos and following tutorials, but this has got me stumped.

Thanks very much to anyone who can help, or provide me with alternate ideas as to make my idea work!

Here’s how I might approach the problem:

#pragma strict
private var qTo : Quaternion;
private var rotateSpeed = 65.0;

function Start() {
	qTo = transform.rotation;

function Update() {
    transform.rotation = Quaternion.RotateTowards(transform.rotation, qTo, Time.deltaTime * rotateSpeed);

function OnGUI() {
	if (GUI.Button(Rect(0,0,100,50), "Next")) {
		qTo = Quaternion.AngleAxis(45.0, Vector3.up) * qTo;
	if (GUI.Button(Rect(0,75,100,50), "Previous")) {
		qTo = Quaternion.AngleAxis(-45.0, Vector3.up) * qTo;