Rotating left or right via keyboard input

I’ve searched around and cant find anything of use.

I’m trying to recreate lunar lander( and am tackling the rotation of the ship but with my current script, the ship will constantly rotate to the right and when I do press input, it will rotate it left correctly.

In my input manager I have ‘Horizontal’ set up to accept the negative button as ‘left’ and positive as ‘right’

Here is my script:

   public class RocketController : MonoBehaviour { 
    private Rigidbody2D rocket;
    public int rotationSpeed;

	void Start () {
        rocket = gameObject.GetComponent<Rigidbody2D>();

	void Update () {
        if (Input.GetButton("Horizontal"))
            rocket.transform.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime);
        }else if (!Input.GetButton("Horizontal"))
            rocket.transform.Rotate(Vector3.back * rotationSpeed * Time.deltaTime);

What your doing in the code is this:
IF (a left/right button is pressed) THEN (rotate to the right);
ELSE IF ( left/right button is NOT pressed) THEN (rotate to the left);


To fix this simply do the following in actual code(so dont copy-paste this because its not actual code): IF(Input.Get(“Horizontal”) >0.5f) THEN (Rotate right); ELSE IF(Input.Get(“Horizontal”)<-0.5f) THEN (rotate left);