L298n speed control not working

I used pin 6 and it still didn't work. for some reason using analogWrite(motor2speedpin, -motorspeed);worked.