How do I set my rotation to my camera's rotation?

I’m trying to walk where my character looks.
What I’m trying to do is change my camera’s z rotation with the mouse, and then set the rotation of the player to the camera’s z rotation. I’ve been trying for an hour or so, and I can’t get it to work. There are no errors.
Here is my code if you need a look.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;

public class Player : NetworkBehaviour
{
	public Canvas canvas;
	public Joystick joystickL;
	public Joystick joystickR;
	public override void OnStartLocalPlayer() {
		Camera.main.transform.SetParent(transform);
		Camera.main.transform.localPosition = new Vector3(0, 0, 0);
		if(Application.platform == RuntimePlatform.Android) {
			canvas.GetComponent<Canvas>().enabled = true;
		}
	}
	
	void Update() {
		float moveX;
		float moveZ;
		float lookY;
		float lookX;
		if(!isLocalPlayer) { return; }
		if(Application.platform == RuntimePlatform.Android) {
			moveX = joystickL.Horizontal * Time.deltaTime * 110.0f;
			moveZ = joystickL.Vertical * Time.deltaTime * 4f;
			lookY = joystickR.Vertical * Time.deltaTime * 110.0f;
			lookX = joystickR.Horizontal * Time.deltaTime * 110.0f;
		} else {
			moveX = Input.GetAxis("Horizontal") * Time.deltaTime * 110.0f;
			moveZ = Input.GetAxis("Vertical") * Time.deltaTime * 4f;
			lookX = Input.GetAxis("Mouse X") * Time.deltaTime * 110.0f;
			lookY = -(Input.GetAxis("Mouse Y")) * Time.deltaTime * 55.0f;			
		}
		
		Camera.main.transform.Rotate(0, lookX, 0);
		transform.rotation = Quaternion.Euler(0, Camera.main.transform.rotation.y, Camera.main.transform.rotation.z);
		transform.Translate(0, 0, moveZ);
		Camera.main.transform.Rotate(lookY, 0, 0);
	}
}

Any help would be great.

In the fnafworld that Scott Cawthon and his development team created there are many interesting things. Five Nights At Freddy’s is always listened to by him and the development team, and they always come up with new levels for players to explore. FNaF game has a fairly simple gameplay, you need to memorize all the information to win.

@somethingidkok as you make the camera child of the player object you should simply just rotate the player and no need to change the cameras rotation.

This fix should work as I tested it.