transform.Rotate will not work

{
public float moveSpeed;
public float rotSpeed;
public Animator anim;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    if (Input.GetKey(KeyCode.W))
    {
        gameObject.transform.Translate(-moveSpeed * Time.deltaTime, 0, 0);
        anim.SetTrigger("WalkForward");
    }
    if (!Input.GetKey(KeyCode.W))
    {
        gameObject.transform.Translate(0, 0, 0);
        anim.SetTrigger("Stop");
    }
    if (Input.GetKey(KeyCode.A))
    {
        //gameObject.transform.Rotate(Vector3.up, -rotSpeed * Time.deltaTime);

        gameObject.transform.Rotate(0, 0, rotSpeed * Time.deltaTime);
        print("turn");
    }
    if (!Input.GetKey(KeyCode.A))
    {
        gameObject.transform.Rotate(0, 0, 0);
    }
}

}
I have use Transform.Rotate countless times in the past and for some reason here it will not work. I have tried going through forums and videos making a dozen tiny tweaks and none of them work. So what am I doing wrong?

Code looks fine, btw “gameObject” in front of .transform is redundant and so are these two parts:

if (!Input.GetKey(KeyCode.W))
     {
         gameObject.transform.Translate(0, 0, 0);
     }

if (!Input.GetKey(KeyCode.A))
     {
         gameObject.transform.Rotate(0, 0, 0);
     }

You do not need to tell your gameobject not to rotate or translate.

And to help you with your problem, I would check these things (I assume that print(“turn”) works):
isn’t rotSpeed set to 0 (e.g. in the inspector)? Isn’t Time.timeScale set to 0? Is this script attached to the correct gameObject?