Calling function from separate script gets buggy

Hello, I have a super weird problem that I have only found a few other people having. The pages I have found of others having the problem didn’t get answered. Some were even lead to believe it was corrupt.

My problem is I have a set of functions that freeze specific objects in the scene for the set amount of time, then unfreezes them. I have a check in the same script as the functions, where anytime i press the “K” key, it calls the function. It works perfectly. It calls it, freezes them, and after the specified time, it unfreezes them. BUT when I call that EXACT same function from a separate script it doesn’t work, not entirely anyway. It will call the function, it freezes the objects, sets the timer, but for some really weird reason, doesn’t count down. Instead they just stay frozen forever.
Here is the code, any help would be awesome. Thanks. This is the GameControllerScript. It has the functions and keypress function call.

function Update{
        if (Input.GetKeyDown(KeyCode.K)){
		FreezeBallsForTime(5);
	}

        if (Level.freeze){
		if (ballsFreezeTimer > 0){
			ballsFreezeTimer -= Time.deltaTime;
			if (ballsFreezeTimer <= 0){
				Level.UnFreezeBalls();
			}
		}
	}
}

function FreezeBallsForTime( waitTime : float ){
	if (Level.freeze == false){
		Level.FreezeBalls();
		Debug.Log("ballsFreezeTimer " + ballsFreezeTimer);
		ballsFreezeTimer = 5;//waitTime;
	}else if (Level.freeze){
		ballsFreezeTimer += waitTime;
	}
}

public class Level
{
	public static var freeze : boolean = false;

	public static function FreezeBalls(){
		if (freeze == false){
			Debug.Log("FreezeBalls() Called");
			freeze = true;
		}
	}

	public static function UnFreezeBalls (){
		Debug.Log("UnFreezeBalls() called");
		freeze = false;
	}
}

And then in the player script

function ActivateFreeze( time : float ){
        gameControllerScript.FreezeBallsForTime(time); //This is referencing the first script. It will call the script fine, and it freezes the balls, but the timer goes all screwy only when not called from the GameControllerScript.
}

if (ballsFreezeTimer > 0){
ballsFreezeTimer -= Time.deltaTime;
if (ballsFreezeTimer <= 0){
Level.UnFreezeBalls();
}
}
if the ballfreezetimer is greater than zero it will count down, but it will never be equal or less than zero to unfreeze them since youve got that bit inside the same check.

             if (ballsFreezeTimer > 0){
                ballsFreezeTimer -= Time.deltaTime;
             }else {
                ballsFreezeTimer = 0.0f;
                 Level.UnFreezeBalls();
             }

and dont forget to uncomment this chunk here:

ballsFreezeTimer = 5;//waitTime;  

to

ballsFreezeTimer = waitTime;

I also noticed youre doing a check for Level.freeze to cause the timer countdown, but when the balls are initially frozen you are just saying “freeze = true”. I dont know your setup, but maybe its tied to this as well…So for consistency sake, either do a check for if(freeze) when the timer is supposed to countdown OR when your balls are frozen do Level.freeze = true;

@Arkaic: Your problem is that you are calling the function from totally another instance of the GameControllerScript! You need to get the same instance of GameControllerScript to have a same timer to count the time correctly.

So, in the Player script try this instead:
GameObject.Find(“ObjectName”).GetComponent<\GameControllerScript>().FreezeBallsForTime(time);

and instead of “ObjectName” above, put the name of the gameObject that the gameControllerScript belongs to.

Edit: In the code I wrote above just ignore the "backslash ()’ before and after GameControllerScript.