Character moving backwards when I press the forward key (w) and moving forward when pressing backwards (s),Character going backwards when pressing the forwards key (w)

void Update()
{

    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

    Vector3 move = transform.right * x - transform.forward * z;

    controller.Move(move*speed*Time.deltaTime);

Make sure the camera is lined up correctly. Let’s say the player is at positon 0 on the z axis and the camera is on z axis 10 when you press the forward key (W) it will look like the player is moving backwards because your camera is not in the correct position to fix this you need to change the camera on the Z axis from 10 to negative 10 and rotate it so that it is facing the player. In other words, your script was right but to solve your problem you just need to change the position of the camera. @PotatoDashYT