[Solved]Rotate gameobject, inside parent gameobject with rotation changing each frame?

I apologize if I can not express myself better because of my level of English its not good.
I hope this pictures and video helps me to explain my problem.

Problem:
I need the rotation of first 5 seconds of video.

PivotX gameObject.

PivotY gameObject

Gun gameObject, child of PivotY


On first time, I used this code:

// Rotation of PivotX gameObject;
PivotX.transform.LookAt(new Vector3(target.transform.position.x, PivotX.transform.position.y, target.transform.position.z));

// Rotation of PivotY gameObject;
PivotY.transform.LookAt(target.transform.position);

the result its same, but with new code I have more posibilites:

My actual code:

//Rotation of PivotX gameObject;
Vector3 targetDir = target.transform.position - PivotX.transform.position;
float step = 100 * Time.deltaTime;
Vector3 newDir = Vector3.RotateTowards(PivotX.transform.forward, targetDir, step, 0.0F);
PivotX.transform.rotation = Quaternion.LookRotation(new Vector3(newDir.x, 0,newDir.z));

//Rotation of PivotY gameObject;
targetDir = target.transform.position - PivotY.transform.position;
newDir = Vector3.RotateTowards(PivotY.transform.forward, targetDir, step, 0.0F);
PivotY.transform.rotation = Quaternion.LookRotation(newDir);

How I can Rotate gun it self?
I try everything, getting BoxCollider.bounds.center, rotateAround, local, and all of posibilities I can find, but I dont know how do it.

All of my trys give same result than:

gun.transform.Rotate(0, 1, 0);

showed on video.

Im sorry again for my english, and thank you for your help.

Finally I found the problem and its fixed:

The pivot of object prefab, was not on center. Only way I found to search pivot of object, is opening object whit Blender or any 3d software, and fix center of pivot on center of object. I dont know how see pivot directly on unity3d.
Now all works with simple code:
gun.transform.Rotate(0,speed,0);

Look to Owen Reynolds explanation. In particular the basic terms and rotation section pdf