First Person Camera Rotation Help

I’m trying to make the camera rotate with key clicks from a first person perspective. I’d like to tie the camera to the direction the game object is moving so that the player is always looking forward, but can still turn.

Here is what I have:

void Update () {
		if (Input.GetKeyDown ("left")) {
			Camera.main.transform.Rotate (Vector3.left, speed * Time.deltaTime);
		}
		if (Input.GetKeyDown ("right")) {
			Camera.main.transform.Rotate (Vector3.right, speed * Time.deltaTime);
		}
		
	}

And I can’t figure out why this doesn’t work.

Try parenting the camera to the gameobject, that way it will folow the object,s movements and it will be able to turn on its own(it will turn inside the parent object’s local space).