for some reason my code seems to rotate my x value to a random position anywhere from 140-170

for some reason my code seems to rotate my x value to a random position anywhere from 140-170
The object always starts at the same rotation but never ends up rotating the same place. does anyone know the problem

{    public float speed;
    public float rotate;
    public bool newRotate;
    public float startTime = 0.3f;
    public float continueTime = 0.0f;
    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
    
        transform.Translate(Vector3.up * Time.deltaTime * Input.GetAxis("Vertical") * speed);
        transform.Translate(Vector3.right * Time.deltaTime * Input.GetAxis("Horizontal") * speed);
      
        if (newRotate == false && Input.GetKeyDown(KeyCode.Space))
        {
            transform.Rotate(Vector3.right * rotate * Time.deltaTime);
            newRotate = true;
        }
        if (newRotate == true && Time.time > continueTime)
        {
            continueTime = Time.time + startTime;
            transform.rotation = new Quaternion(-500, 0, 0, 0);
            newRotate = false;
        }
        }
}

Anytime you are using Time.deltaTime, if a single frame takes a little less or more time, then there will be differences between runs.

Normally this is desirable, to give the same overall movement (or in this case rotation) per second.

ALSO, line 27 above is not meaningful. If you are looking to rotate by -500 degrees, the correct function to use is:

transform.rotation = Quaternion.Euler( -500,0,0);

The four-element constructor for a Quaternion is the internal matrix terms x,y,z,w and have no meaning with regard to degrees of rotation. The above factory constructor is used instead and does the heavy lifting to produce an internal x,y,z,w you never have to see based on the x,y,z angles you put in.

I admit it is a bit confusing because the same x,y,z are reused and mean something COMPLETELY different. You can check the linear math behind it if you care, but I just use the .Euler() function.