Day-Night-changing error.

Hello,
I think my problem is quiet simple, but can’t solve it. In the script i made IF statement, which doesn’t execute even if it is true… (this script is attached to directional light).
Here is the script:

#pragma strict

var daySpeed : float;

function Start() {
    daySpeed = 0.2;
}

function Update() {

  transform.Rotate(daySpeed,0,0);

  if(transform.rotation.x > 350 && transform.rotation.x < 360) {
        Night();
  }
  else {
    daySpeed = 0.2;
  }
}

function Night() {
    daySpeed = 0.01;
}

It looks as if you never increment the transform. Try:

#pragma strict
 
var daySpeed : float;
 
function Start() {
    daySpeed = 0.2;
}
 
function Update() {
 
 // transform.Rotate(daySpeed,0,0);  //Instead of this

//This is C# formatting

transform.EulerAngles = new Vector3 (transform.EulerAngles.x + daySpeed, 0,0);

 
  if(transform.rotation.x > 350 && transform.rotation.x < 360) {
        Night();
  }
  else {
    daySpeed = 0.2;
  }
}
 
function Night() {
    daySpeed = 0.01;
}