Tank Tower Problem

Hi guys, i’m new here and i have a stupid question to you

Now i am trying to create a 3d tank Game and i have made a Tank simple script and a cannon shot script, but in the TankSimpleScript i have a problem with the tower:
When the Tank body (the parent of all other parts) turn forward or sideway, the tower still stay in the same position ( it doesn’t turn with the body) but it turns only on the Y axis. please help ( sorry for my bad english, cause i’m not english ). if you need the script here it is.

//VARIABILI PER LA TORRETTA E IL CANNONE

var Tower : Transform;
var MainGun : Transform;
var xSpeed = 0.2;
var ySpeed = 0.2;
private var x = 0.0;
private var y = 0.0;

//VARIABILI PER IL MOVIMENTO
//Cingoli
var Tracks : Transform;
var scrollSpeed : float;

//Ruote di sinistra Colliders
var LeftWheel01 : WheelCollider;
var LeftWheel02 : WheelCollider;
var LeftWheel03 : WheelCollider;
var LeftWheel04 : WheelCollider;
var LeftWheel05 : WheelCollider;
var LeftWheel06 : WheelCollider;
var LeftWheel07 : WheelCollider;

//Ruote di destra Colliders
var RightWheel01 : WheelCollider;
var RightWheel02 : WheelCollider;
var RightWheel03 : WheelCollider;
var RightWheel04 : WheelCollider;
var RightWheel05 : WheelCollider;
var RightWheel06 : WheelCollider;
var RightWheel07 : WheelCollider;

//Ruote di DESTRA Meshes
var R_Wheel01 : Transform;
var R_Wheel02 : Transform;
var R_Wheel03 : Transform;
var R_Wheel04 : Transform;
var R_Wheel05 : Transform;
var R_Wheel06 : Transform;
var R_Wheel07 : Transform;

//Ruote di SINISTRA Meshes
var L_Wheel01 : Transform;
var L_Wheel02 : Transform;
var L_Wheel03 : Transform;
var L_Wheel04 : Transform;
var L_Wheel05 : Transform;
var L_Wheel06 : Transform;
var L_Wheel07 : Transform;

var MaxSpeed : float = 80.0;
var MaxSteer = 0.0;
var MaxTorque = 10;
var BrakesForce = 100;

private var steer = 0.0;
private var motor = 0;
private var brake = 0;
private var forward = 0;
private var back = 0;
private var reverse = false;
private var speed = 0;

function Start () 
{
    rigidbody.centerOfMass = Vector3(0,-0.8,0);
    var angles = transform.eulerAngles;
    x = angles.y;
    y = angles.x;
    if (rigidbody)
        rigidbody.freezeRotation = false;
}

function Update () 
{
    // MOVIMENTO DELLA TORRETTA E DEL CANNONE
    x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
    y += Input.GetAxis("Mouse Y") * ySpeed * 0.02;
    
    var rotationY = Quaternion.EulerRotation(0,x,0);
    var rotationX = Quaternion.EulerRotation(y,x,0);
    
    Tower.transform.rotation = rotationY;
    MainGun.transform.rotation = rotationX;

    //PARTE DELLO SCRIPT CHE MANIPOLA IL MOVIMENTO, ACCELERAZIONE, FRENI, STERZATA
    steer = Mathf.Clamp(Input.GetAxis("Horizontal"),-1,1);
    forward = Mathf.Clamp(Input.GetAxis("Vertical"), 0, 1);
    back = -1 * Mathf.Clamp(Input.GetAxis("Vertical"), -1, 0);
    Brakes = -2 * Mathf.Clamp(Input.GetAxis("Vertical"), -1, 0);
    scrollSpeed = speed;
    
    var offset : float = Time.time * scrollSpeed;
    Tracks.renderer.material.SetTextureOffset("_MainTex", Vector3(0,offset,0));
    
    if(speed == 0.0) 
    {
        if(back > 0.0) 
        { 
            reverse = true; 
        }
        if(forward > 0.0) 
        {
            reverse = false; 
        }
    }
    if(speed > MaxSpeed)
    {
        speed = MaxSpeed;
    }
    if(reverse) 
    {
        motor = -1.0 * back;
        brake = forward;
    } 
    else
    {
        motor = forward;
        brake = Brakes;
    }
    if(steer)
    {
        transform.rotation = transform.rotation * Quaternion.EulerRotation(0,steer * MaxSteer,0);
    } 
    
    //Ruote di SINISTRA accelerazione
    LeftWheel01.motorTorque = MaxTorque * motor;
    LeftWheel02.motorTorque = MaxTorque * motor;
    LeftWheel03.motorTorque = MaxTorque * motor;
    LeftWheel04.motorTorque = MaxTorque * motor;
    LeftWheel05.motorTorque = MaxTorque * motor;
    LeftWheel06.motorTorque = MaxTorque * motor;
    LeftWheel07.motorTorque = MaxTorque * motor;
    
    //Ruote di SINISTRA freno
    LeftWheel01.brakeTorque = BrakesForce * brake;
    LeftWheel02.brakeTorque = BrakesForce * brake;
    LeftWheel03.brakeTorque = BrakesForce * brake;
    LeftWheel04.brakeTorque = BrakesForce * brake;
    LeftWheel05.brakeTorque = BrakesForce * brake;
    LeftWheel06.brakeTorque = BrakesForce * brake;
    LeftWheel07.brakeTorque = BrakesForce * brake;
    
    //Ruote di DESTRA accelerazione
    RightWheel01.motorTorque = MaxTorque * motor;
    RightWheel02.motorTorque = MaxTorque * motor;
    RightWheel03.motorTorque = MaxTorque * motor;
    RightWheel04.motorTorque = MaxTorque * motor;
    RightWheel05.motorTorque = MaxTorque * motor;
    RightWheel06.motorTorque = MaxTorque * motor;
    RightWheel07.motorTorque = MaxTorque * motor;
    
    //Ruote di DESTRA freno
    RightWheel01.brakeTorque = BrakesForce * brake;
    RightWheel02.brakeTorque = BrakesForce * brake;
    RightWheel03.brakeTorque = BrakesForce * brake;
    RightWheel04.brakeTorque = BrakesForce * brake;
    RightWheel05.brakeTorque = BrakesForce * brake;
    RightWheel06.brakeTorque = BrakesForce * brake;
    RightWheel07.brakeTorque = BrakesForce * brake;
    
    //Ruote di SINISTRA rotazione
    L_Wheel01.Rotate(LeftWheel01.rpm * 5 * Time.deltaTime,0,0);
    L_Wheel02.Rotate(LeftWheel02.rpm * 5 * Time.deltaTime,0,0);
    L_Wheel03.Rotate(LeftWheel03.rpm * 5 * Time.deltaTime,0,0);
    L_Wheel04.Rotate(LeftWheel04.rpm * 5 * Time.deltaTime,0,0);
    L_Wheel05.Rotate(LeftWheel05.rpm * 5 * Time.deltaTime,0,0);
    L_Wheel06.Rotate(LeftWheel06.rpm * 5 * Time.deltaTime,0,0);
    L_Wheel07.Rotate(LeftWheel07.rpm * 5 * Time.deltaTime,0,0);

    //Ruote di DESTRA rotazione
    R_Wheel01.Rotate(RightWheel01.rpm * 5 * Time.deltaTime,0,0);
    R_Wheel02.Rotate(RightWheel02.rpm * 5 * Time.deltaTime,0,0);
    R_Wheel03.Rotate(RightWheel03.rpm * 5 * Time.deltaTime,0,0);
    R_Wheel04.Rotate(RightWheel04.rpm * 5 * Time.deltaTime,0,0);
    R_Wheel05.Rotate(RightWheel05.rpm * 5 * Time.deltaTime,0,0);
    R_Wheel06.Rotate(RightWheel06.rpm * 5 * Time.deltaTime,0,0);
    R_Wheel07.Rotate(RightWheel07.rpm * 5 * Time.deltaTime,0,0);
    
    //MainWheels rotazione
    M_Wheel01.Rotate(LeftWheel01.rpm * 5 * Time.deltaTime,0,0);
    M_Wheel02.Rotate(LeftWheel01.rpm * 5 * Time.deltaTime,0,0);
}


static function ClampAngle (angle : float, min : float, max : float) 
{
    if (angle < -360)
        angle += 360;
    if (angle > 360)
        angle -= 360;
    return Mathf.Clamp (angle, min, max);
}

If you need a video to understand better my problem tell me :wink:
Thanks all of you.

***hides from the big scary code-wall***

…not sure, but try changing this single line

Tower.transform.rotation = rotationY;

to->

Tower.transform.localRotation = rotationY ;

and see what happens with that.