Enable/Disable Child Script

Hey guys. I’ve been working on a script that makes it so that when the player presses the space bar, it disables/enables the simple mouse rotator component attached to the player and the main camera “using the standard assets beta character prefab” However, I’m getting these errors:
Modified Cursor.js(6,62): BCE0005: Unknown identifier: ‘SimpleMouseRotator’.
and
Modified Cursor.js(7,54): BCE0005: Unknown identifier: ‘SimpleMouseRotator’.

Can someone tell me what I did wrong?

The Script:

 var changeToggle : boolean;
 var script : SimpleMouseRotator;
 var script2 :  SimpleMouseRotator;
 
 function Start() {
 	script = GameObject.Find("Main Camera").GetComponent(SimpleMouseRotator);
    script2 = GameObject.Find("Player").GetComponent(SimpleMouseRotator);
 }
 function Update (){
     if (Input.GetKeyDown("space")){
             if(changeToggle)
                 Screen.lockCursor = true;
                 script.enabled = true;
                 script2.enabled = true;
              }
              else
              {
                 script.enabled = false;
                 script2.enabled = false;
                 Screen.lockCursor = false;
                 changeToggle = !changeToggle;
     }
 }

// use nameofscript as the script name
getcomponent();
// for some reason it doesn’t allow <> in comments

if the simpleroater script is a CHILD of the player gameobject, and you are running this script from the player, then you would do something like:

for(var child : Transform in transform){
 if(child.name == "the name of the object with the script"){
   child.GetComponent(simplerotater).enabled = false;
 }
}

Also, it looks as if you are checking for a script on the player object, when you said it was a child, so you should be finding the child object. gameobject.find(“the child object name”).getcomponent(thechildscript)–etc

edit: can’t believe I missed this, but you don’t have a { after the changetoggle if statement. Nor do you have a } following the chunk of stuff done after the else statement. Is that your problem?

unity is basically reading your code like this:

  function Update (){
      if (Input.GetKeyDown("space")){
              if(changeToggle){
                  Screen.lockCursor = true;
              }
              script.enabled = true;
              script2.enabled = true;
      }else{
              script.enabled = false;
              script2.enabled = false;
              Screen.lockCursor = false;
              changeToggle = !changeToggle;
      }
  }