Remotely tweaking a script via script.

I have a script attached to the camera which does something when the left-mouse-button is used. I want to uncheck "Can Control" in the Character Motor script on the player object. How?

Edit

var sound1 : AudioClip;
var tempbrick : GameObject;
var burst : ParticleEmitter;

function Update () {

if (Input.GetButtonDown("Fire1")) {

var ray : Ray = Camera.main.ViewportPointToRay (Vector3(0.5,0.5,0));   
    var hit : RaycastHit;
    if (Physics.Raycast (ray, hit, 7)) {

        Debug.DrawLine (ray.origin, hit.point);

        Instantiate(tempbrick, hit.point, Quaternion.identity);
        Instantiate(burst, hit.point, Quaternion.identity);

        audio.PlayOneShot(sound1);

        var script : CharacterMotor;
        script = GetComponent ("Can Control");

        script.enabled = false;

        }

    Physics.Raycast (ray, hit);

    }

Debug.DrawRay (ray.origin, ray.direction * 10, Color.white);

}

The console is giving me "NullReferenceException: Object reference not set to an instance of an object".

alt text

That is what I want to disable. The previous script is on a separate object.

You could use the function GetComponent. In the reference there are also examples how to access script components.


Edit:

I am not sure how your script looks like, but it could look something like this:

var script : CharacterMotor;

function Start() {
  script = GetComponent("CharacterMotor");
}

function Update () {
  CharacterMotor.CanControl.enabled = false;
  ...
}