How do I make code not work on a child

I want my player to look right when you press the right arrow key and left when you press the left arrow key
The catch is the camera is a child of the player, and it flips the camera’s Z axis. I want the camera’s position on the z axis to stay the same. How do I do that??

note it’s a 2D game

I’m guessing you want the camera to follow player but not receive rotations, what I’ve done in the past is create my own parenting script, basically a simple Update the sets the position of the “child” with an offset based off the parent. e.g.

using UnityEngine;
using System.Collections;

public class Testing : MonoBehaviour 
{
	public GameObject parent;
	public Vector3 offset;
	void Update () 
	{
		transform.position = parent.transform.position + offset;
	}
}