Rotate child object ?

Hi
My problem here is with the child object that rotate with the main object. the main object rotate on Y axis only but the child use X axis only. but it doesn’t work like this. the whole object rotate on Y & X axis !!
Here is my script:

public float z_angle;
public float x_angle;
public float min_x,max_x;
public float min_z,max_z;

public Transform target;
public float dist;

public Transform base1; // child

// Update is called once per frame
void Update () {

    dist = Vector3.Distance(gameObject.transform.position, target.transform.position);

    if (dist <= 50) {
        Vector3 charAngle = gameObject.transform.eulerAngles;
        charAngle.z = (charAngle.z > 180) ? charAngle.z-360 : charAngle.z;
        charAngle.z = Mathf.Clamp(charAngle.z, -min_z, max_z);
        z_angle = charAngle.z;
        gameObject.transform.rotation = Quaternion.Euler(charAngle);

        Vector3 charAnglex = base1.transform.eulerAngles;
        charAnglex.x = (charAnglex.x > 180) ? charAnglex.x-360 : charAnglex.x;
        charAnglex.x = Mathf.Clamp(charAnglex.x, -min_x, max_x);
        x_angle = charAnglex.x;
        base1.transform.rotation = Quaternion.Euler(charAnglex);

        var rotation = Quaternion.LookRotation(target.position - transform.position);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2.5f);

    }

}

The child will rotate with the parent. If you don’t want that, you have to position them together in the script.

Yes, i want child rotate with the parent but parent not rotate with the child axis.
parent rotate Y angle. child rotate X angle.

If I understand your question right, you want to zero out the target rotation for the parent object’s x axis.
Then, moving the y-axis for the parent moves both the parent and the child (automatically, by just moving the parent). Next, set the localRotation of the child’s x-axis

Yeah, something like:

Vector3 adjustedTargetPos = new Vector3(target.position.x,transform.position.y,target.position.x);