Camera rotation the same as player rotation

Hello, i am trying to create a space game, where i have created a planet. I have created 2 scripts that makes the player stick to the planet and rotate so he’s feet will always be grounded. Thats perfect, but then i have a third person camera, which rotates to the right and left, up and down which is also perfect. But the problem is that when i walk on the planet until i’m on the side of it, my player is rotated 90 degrees kind off, and thats what the player should do, but then the camera is still rotated on the z on 0, and not rotated 90 degrees. What i am trying to do is to make the camera so it follows the players Z rotation, which for some reason i just dont know how to script.

Question : How to make the cameras rotation Z be the same as the players rotation Z ?

Without your scripts its hard to tell, but it should be something simple like:

camera.transform.rotation = new Quaternion (camera.transform.rotaion.x, camera.transform.rotaion.y, player.tranform.rotaion.z, //whatever you want your w to be//);

Like I said without your scripts it can be hard to tell, but I hope that this might help.