How to make a flashlight (childed to the player) rotate with the player?

So I’m making a hospital horror game and was trying to figure out how to make the flashlight rotate up and down as the player rotates up and down (same x rotation, basically), but the script says that when I try to set the flashlight’s rotational x value (this is in fixed update by the way) equal to the player’s rotational x value, the error given is this:

“Assets/Scripts/FlashlightLook_Y.cs(12,22): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.rotation’. Consider storing the value in a temporary variable”

I don’t know how this works or how to correct the error, so someone please give me some help and tell me how to do this.
Thanks in advance!
Also P.S. maybe we could work together?? IDK it’s just an idea but thanks a ton!!

You need to store value of rotaion in some variable first.

var rot= transform.rotaion;

Then you can change value of

rot.x = player.x;

Don’t forget to reassign value to the rotation.

transform.rotation = rot;