How to let a child object look at the position of the mouse without rotating the parent object

I want to make a tank.
A tank has a shooting pipe.
The shooting pipe is the child of the tank.

I only want the shooting pipe (child of tank) look at the position of the mouse

Put this code on your shooting pipe, and it should work:

    public Camera cam;

    private void Update()
    {
        //getting the position and rotation to shoot the ray
        Ray ray = cam.ScreenPointToRay(Input.mousePosition);

        //making variable for storing raycast data
        RaycastHit hit;

        //shooting the ray and detecting if it hit something
        if (Physics.Raycast(ray, out hit))
        {
            //looking at the point the ray hit
            transform.LookAt(hit.point);
        }
    }

This code shoots a raycast from your mouse position and then rotates the object to that position.