i cant figure out to rotate a game object by 90 degrees, i try this and i didn't work

using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerMovement : MonoBehaviour
{
    [Header("Player")]
    public GameObject player;
    public float speed;
    private Transform position;
    private Rigidbody rb;

    [Header("Key Bind")]
    public KeyCode movForward;
    public KeyCode movbackward, rotRight, rotLeft;

    public void Start()
    {
        position = player.GetComponent<Transform>();
        rb = player.GetComponent<Rigidbody>();
    }

    public void FixedUpdate()
    {

        if(Input.GetKeyDown(movForward))
        {
            rb.AddForce(position.forward * speed);
        }

        if(Input.GetKeyDown(movbackward))
        {
            rb.AddForce(-position.forward * speed);
        }

        if(Input.GetKeyDown(rotLeft))
        {
            if(player.GetComponent<Transform>().transform.localRotation.y == 0)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, -90, 0);
            }

            if (player.GetComponent<Transform>().transform.localRotation.y == -90)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, -180, 0);
            }

            if (player.GetComponent<Transform>().transform.localRotation.y == -180)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, -270, 0);
            }

            if (player.GetComponent<Transform>().transform.localRotation.y == -270)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, 0, 0);
            }
        }

        if (Input.GetKeyDown(rotRight))
        {
            if (player.GetComponent<Transform>().transform.localRotation.y == 0)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, 90, 0);
            }

            if (player.GetComponent<Transform>().transform.localRotation.y == 90)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, 180, 0);
            }

            if (player.GetComponent<Transform>().transform.localRotation.y == 180)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, 270, 0);
            }

            if (player.GetComponent<Transform>().transform.localRotation.y == 270)
            {
                player.GetComponent<Transform>().eulerAngles = new Vector3(0, 0, 0);
            }
        }
    }
}

*I can’t figure out to rotate a game object by 90 degrees, I tried this and it didn’t work

Hey and welcome. Please have a read at this for how to properly report a problem: How to report a problem in the Unity3D forums – PLBM Games

That said, to rotate something you can just get the current value and add your rotation value to that. I also assume that PlayerMovement is attached to the player object, so we can just write transform instead of GetComponent:

// This is the shortest way
transform.eulerAngles += new Vector(0,90,0);

// And for subtraction accordingly with a minus:
transform.eulerAngles -= new Vector(0,90,0);

// You can do this if you like it more for readability in the beginning of learning to programm, but it's really just longer.
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y + 90; transform.eulerAngles.z);

One other thing would be that you do not want to do anything besides physics in FixedUpdate. This includes input checking. Input checking is normally handled in Update. You then either remember the key, change the state of your statemachine, or precalculate the force you want to apply in FixedUpdate later on. Do not worry too much about this if you just started out, but keep that in mind for scripts you write in the future when you feel more comfortable. It’s very important for performance reasons, as slowing down FixedUpdate can cause exponential slowdowns to your game, whereas slowing down Update only causes roughly linear slowdown for your game. This is because Unity tries to make sure FixedUpdate is called in fixed timesteps. So the longer the execution of FixedUpdate takes, the less time there is to render actual frames between the execution of FixedUpdate.
Also, anything that does not directly have to do with physics (so basically rigidbody stuff) does not have to go into FixedUpdate at all. Since you handle your rotation through transform and not Rigidbody.MoveRotation, you could put all of that into Update. Then again, maybe you actually want to use Rigidbody.MoveRotation instead. The difference is basically that changing the transform directly is similar to “teleporting” the object, while letting the Rigidbody method handle this change includes collision checks and so on. It’s mostly useful for smooth rotations, so i doubt it makes a difference when turning 90° in a single frame.