Possible to lock a variable like moveSpeed?

In the 3D Platform Tutorial there is a ThirdPersonController script that utilizes a private variable called “moveSpeed”. I have made the variable just a regular var by deleting “private” from the line of code so that I can use it in the ThirdPersonStatus script. I am doing this because I would like to achieve a completely motionless character upon respawn, otherwise if the character is moving upon death he carries over the motion values when respawned. In other words, if the character is flying through the air or is running when killed, he respawns with that motion still going and then comes to a stop so long as you aren’t pressing anything on your input device. So again, I was trying to manipulate the moveSpeed variable to “0” when he respawns, and I have achieved this by using these lines of code:

var controller: ThirdPersonController;
	controller = GetComponent(ThirdPersonController);
        controller.moveSpeed = 0.0;

this is used in the function Die() of the ThirdPersonStatus script. My question goes beyond this though. I was wondering if for some reason ever that I want to lock a variable in another script, that is, keep it from changing despite what you press on your input device, how would I do that? I understand there is a “lock” operator in Javascript but I do not know how it is used. I was thinking along the lines of this:

lock.controller.moveSpeed;

//or

controller.moveSpeed.lock;

but when I use either of these (not at the same time, of course) I get this error: “Expressions in statements must only be executed for their side-effects.” I do not know what this means, I am still learning. I am just wondering because it would be good to know how to disable the moveSpeed temporarily, if I wanted, for what ever purpose related to the game it’s used in. I’ve also tried using

controller.moveSpeed.enabled = false;

but that doesn’t seem to work either. What can I use to “lock” a variable to what ever value at any given time? Thank you for your time!

I’m not sure how it is done in UnityScript.

In C# you could use a bool variable and a property to “lock” your variable.

    public bool LockMoveSpeed;

    private float moveSpeed;
    public float MoveSpeed
    {
        get { return value; }
        set
        {
            if (!LockMoveSpeed)
                moveSpeed = value;
        }
    }

why not just set movespeed to 0 upon death or reset all variables???