Odd rotation on a pipe

I have a script that lets there player spawn, rotate, and place pipe. We have 3 different pipes that we play with, Straight, T-Joint, and Corner. The first 2 work great but the 3rd one keeps rotating on the wrong axis no matter what axis I try to rotate. If I rotate through the inspector it rotates how I want it to though. So whats going on?

if(Input.GetButtonDown("Rotation") && buildingThree.rotateEnabled == true)
 			{
 				structure.transform.Rotate(0,Input.GetAxisRaw("Rotation") * 45,0);
 			}

Not sure what you’re doing - it works for me…

Pipes

Create a new Scene and drop this on the Main Camera:

using UnityEngine;
using System.Collections;

public class PipeRotation : MonoBehaviour {

	GameObject[] pipes = new GameObject[3];
	GameObject selector;
	int sel = 1;
	bool animating = false;
	void Start () {
		Camera.main.gameObject.AddComponent<Light>().range = 30;
		pipes[0] = Cyl(0,-3.5f,0, 0,0,0, 3,0.1f,3);
		pipes[1] = Cyl(0,-3.5f,0, 0,0,0, 3,0.1f,3);
		pipes[2] = Cyl(0,-3.5f,0, 0,0,0, 3,0.1f,3);
		Cyl(0,-3,0, 90,0,0, 1,1.5f,1).transform.parent = pipes[0].transform;

		Cyl(0,-3,0, 90,90,0, 1,1.5f,1).transform.parent = pipes[1].transform;
		Cyl(0,-3,-0.75f, 90,0,0, 1,0.75f,1).transform.parent = pipes[1].transform;

		Cyl(0.75f,-3,0, 90,90,0, 1,0.75f,1).transform.parent = pipes[2].transform;
		Cyl(0,-3,-0.75f, 90,0,0, 1,0.75f,1).transform.parent = pipes[2].transform;
		Cyl(0,-3,0, 0,0,0, 1,0.5f,1).transform.parent = pipes[2].transform;
        
		pipes[0].transform.position += Vector3.left*4;
		pipes[2].transform.position += Vector3.right*4;

		selector = Cyl(0,-3.5f,0, 0,0,0, 3.5f,0.05f,3.5f);
    }

	GameObject Cyl(float x, float y, float z,
	               float rx, float ry, float rz,
	               float sx, float sy, float sz) {
		GameObject o = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
		o.transform.position = new Vector3(x, y, z);
		o.transform.rotation = Quaternion.Euler(rx, ry, rz);
		o.transform.localScale = new Vector3(sx, sy, sz);
        return o;
	}
	
	void Update () {
		float osc = 0.5f * Mathf.Sin(10*Time.time);
		selector.transform.localScale = new Vector3(3.5f+osc,0.05f,3.5f+osc);
		if (!animating)
		{
			float horiz = Input.GetAxisRaw("Horizontal");
			if (Mathf.Abs(horiz)>0.5f)
			{
				sel = (sel + 3 + (int)Mathf.Sign(horiz)) % 3;
				StartCoroutine(MoveSelector());
			}
			float vert = Input.GetAxisRaw("Vertical");
			if (Mathf.Abs(vert)>0.5f)
			{
				StartCoroutine(RotatePipe(Mathf.Sign(vert)));
            }
        }
	}

	IEnumerator MoveSelector() {
		animating = true;
		Vector3 target = new Vector3(sel*4-4,-3.5f,0);
		while(selector.transform.position != target)
		{
			selector.transform.position = Vector3.MoveTowards(selector.transform.position, target, 0.3f);
			yield return null;
        }
		animating = false;
    }

	IEnumerator RotatePipe(float direction) {
		animating = true;
		GameObject pipe = pipes[sel];
		Quaternion target = pipe.transform.rotation * Quaternion.Euler(0,direction*90,0);
		while(pipe.transform.rotation != target)
		{
			pipe.transform.rotation = Quaternion.RotateTowards(pipe.transform.rotation, target, 3f);
			yield return null;
        }
        animating = false;
    }
    
}