nullrefrenceexception: how can i solve this?

so, ive been looking for 3 hours now, and i cant find why this is giving me an error, what im trying to do, is to lock the player (maxsidewaysspeed = 0.0f, jumping = false) and set the gravity, to get a thwomp powerup effect, so what im doing is: detecting if the player has obtained the speed powerup (you see it trying to check if the player has a maxSidewaysSpeed of 9.0f, wich is the value that the boost gives) then im checking if the player attacks, then i set all the variables. after that in the else, im setting the values back with the speedBoost value from earlier. im trying to access the standard script CaracterMotor. they arent on the same gameObject, nor are they in the same folder. here is my code:

#pragma strict

static var attack : boolean;
static var speedBoost : boolean;

function Start () {

}
function Update () {
	
		if(script.movement.maxSidewaysSpeed == 9.0f){
			speedBoost = true;
		}
		else{
			speedBoost = false;
		}
	
	
	
var script : CharacterMotor = GetComponent(CharacterMotor);
	
	var AT = gameObject.GetComponent(AnimateTexture);
	if(Input.GetMouseButton(0) && attack){
		AT.rowNumber = 4; 
		script.movement.maxSidewaysSpeed = 0.0f;
		script.movement.gravity = 70.0f;
		script.jumping.jumping = false;
	}
	  else if(Input.GetKey("a")){
		AT.rowNumber = 3;
	} else if(Input.GetKey("d")){ 
		AT.rowNumber = 1; 
	} else if(Input.GetKey("left")){
		AT.rowNumber = 3;
	} else if(Input.GetKey("right")){
		AT.rowNumber = 1;
	} else { 
	AT.rowNumber = 0; 
	if(speedBoost){
		script.movement.maxSidewaysSpeed = 9.0f;
		script.movement.gravity = 20.0f;
		script.jumping.jumping = true;
	}
	else{
		script.movement.maxSidewaysSpeed = 6.0f;
		script.movement.gravity = 20.0f;
		script.jumping.jumping = true;
	}
	}
}

please help me, im stuck!

thanks in advance!

If your CharacterMotor isnt on the same GameObject, why are you trying to find it on the same GameObject? Look at this line:

var script : CharacterMotor = GetComponent(CharacterMotor);

“GetComponent” searches only on the GameObject the script is attached to! Try to make it a public var and set it in the Inspector.

public var script : CharacterMotor;