Freeze Script on Escape Key?

My current code isn’t working and I’m not sure why.

When I press the escape key, I want it to stop the script (MouseLook) and restart it when I press escape again, why isn’t this working?

var FreezeScreen : boolean = false;

function CheckFreeze () {

if(Input.GetKeyDown(KeyCode.Escape)) {

FreezeScreen = !FreezeScreen;

}

if(FreezeScreen == true) {

GetComponent(MouseLook).enabled = false;

}

if(FreezeScreen == false) {

GetComponent(MouseLook).enabled = true;

}

}

up?

What exactly is going wrong with this code?
Is it throwing an exception?
Just doing nothing?
Is CheckFreeze() called from an Update method?
Is this script attached to an object that also has a MouseLook component?

The last one is true, and what’s happening is it isn’t freezing anything, I’m not sure what I need to do…

CheckFreeze() needs to be called from an Update function somewhere or just change the name of CheckFreeze to Update.

Time.timeScale = 0; its gonna freeze everything and if Time.timeScale = 1.0 then everything will be normal

This will have multiple people in game though, what you said would freeze it for everyone correct?

I might just be stupid, but this isn’t working…my code now:

Up…

Up…

still doing nothing? Is this on a webplayer? If so, the escape key is a little funky there.
This link could get you to where you want to be.

This helped a lot, thank you.