Why isn't this public variable working? (JS)

Good day, everyone!

I have a public variable in this JS script that for some reason, doesn’t affect anything when I change it while running the game.
The speedOfLight starts as “1”. It is a multiplier for how fast the sun should rotate around the world. If I set it manually in the script, it works. If I set it in the editor, It has no effect on the speed the light moves.

You can attach the code to a directional light to see what it does, if you’d like.

#pragma strict

public var normalPassageOfTime = true;

//How many degrees the sun rotates per second
private var degreesOfRotation : float = 360f /*degrees*/ / 24f /*hours*/ / 60f /*minutes*/ / 60f /*seconds*/;

//Visible variable to adjust speed of time flow
public var speedOfLight : float = 1f;

//Calculation of time flow speed
private var speedModifier : float = degreesOfRotation * speedOfLight;

//Get Hours, Minutes, and Seconds as a string
public var currentHour = System.DateTime.Now.ToString("HH");
public var currentMin = System.DateTime.Now.ToString("mm");
public var currentSec = System.DateTime.Now.ToString("ss");

//Convert current number of hours/minutes passed since midnight into usable seconds
//Seconds will just equal current as a float
private var hoursInSeconds : float = parseFloat(currentHour) * 60f * 60f;
private var minutesInSeconds : float = parseFloat(currentMin) * 60f;
private var secondsInSeconds : float = parseFloat(currentSec);

function Awake() {
//set position of the sun based on time of day
	transform.Rotate(0,0,degreesOfRotation * (hoursInSeconds + minutesInSeconds + secondsInSeconds));

}

function Start () {
	
	
}

function Update () {
	//rotate the sun based on set speed (Needs Variables adjusted)
	if (normalPassageOfTime == true) {
		transform.Rotate(0,0,speedModifier * Time.deltaTime);
		}
	
}

It’s probably worth noting that if you are watching for the light to move at normal speed, you aren’t going to notice it. I have it set up to move at a real time of day rate.

By the way, I’ll take this moment to pat myself on the back, as this is the first script I’ve ever written, and I did it all with my noodle (except for looking up syntax things about JS). Very proud of myself.
Roll your eyes at the new guy if you must. :wink:

Is it maybe a bug in Unity that is preventing this from being effective?

Thank you, everyone in the community!

In uJS leave out the ‘f’. You should add the .0 though.

Dont do this in the globals…

private var speedModifier : float = degreesOfRotation * speedOfLight;

Declare it globally and initialise it in a function.

private var speedModifier : float; 
function Start()
{
    speedModifier = degreesOfRotation * speedOfLight;
}