Changing Crosshairs with stance.

I’m working with a group of people and none of us seem to be able to get our crosshairs to change texture from standing to crouched. plz help.

this is the code 4 the crosshairs.

#pragma strict
var crosshairTexture : Texture2D;
var position : Rect;
static var OriginalOn = true;

function Start() {

}

function Update() {
	position = Rect((Screen.width - crosshairTexture.width) / 2, (Screen.height - crosshairTexture.height) / 2, crosshairTexture.width, crosshairTexture.height);
}

function OnGUI() {
	if(OriginalOn == true) {
		GUI.DrawTexture(position, crosshairTexture);
	}
}

//this is the code for the stances.

#pragma strict
private var walkSpeed: float = 8; // regular speed

private var runSpeed: float = 15;    // run speed
 
private var crouchSpeed: float = 3;  // crouching speed
 
private var speed: float;           // the current speed state
 
var maxFatigue: int = 100; 
 
var fatigue : float = 100; 

var fatigueBarLength: float = Screen.width / 2;

var sprintCoolDown : float = 5.0;
 
private var crouchHeight : float;     // variables for character height while crouching
 
private var crouchingHeight : float;  
 
private var standingHeight: float;    // height of character while standing
 
private var crouching = false;        // boolean is crouching?
 
private var running = false;          // boolean is running?
 
 
 
private var characterMotor: CharacterMotor;  //direct variable to the characterMotor
 
private var mainCamera: GameObject;          // direct variable to the mainCamera
 
 
 
function Start(){
 
    //initialize
 
    characterMotor = GetComponent(CharacterMotor);
 
    mainCamera = gameObject.FindWithTag ("MainCamera");
 
    standingHeight = mainCamera.transform.localPosition.y;
 
    crouchingHeight = (standingHeight / 2);
 
    crouchHeight = (standingHeight - crouchingHeight);
 
}
 
 
 
function Update(){
 
 
 
    //simple machine for setting the current speed of the character
 
    if( crouching ){
 
        speed = crouchSpeed;
 
    }else if( running ){
 
        speed = runSpeed;
 
    }else{
 
        speed = walkSpeed;
 
    }
 
 
 
    //If the sprint button is clicked, and not crouching .. SPRINT!
 
    if (Input.GetKey(KeyCode.LeftShift)){
 
        if(!crouching){
        	if(fatigue > 0){  
        		if(sprintCoolDown == 5.0){        		     		 
            		running = true;
            	}else{
            		running = false;
            		}
            }else{
            	running = false;

 			}
        }
 
    }else {
 
 
        running = false;
 
    }
 	if(running == true){
 		fatigue -= 0.5; 
 	}else{
 		fatigue += 0.25;
 		}
 
	if(fatigue > 100){
		fatigue = 100;
	}
	if(fatigue < 0) {
		fatigue = 0;
	}
	if(fatigue == 0){
		sprintCoolDown = 0;
		}
	if(sprintCoolDown > 5.0){
		sprintCoolDown = 5.0;
		}
	if(sprintCoolDown < 5.0){
		sprintCoolDown += 0.05;
		}
 	
 	fatigueBarLength = (Screen.width / 2) * (fatigue / maxFatigue);
 
    // if crouch button has been pressed, put FPS into crouch
 
    if (Input.GetKeyUp(KeyCode.LeftControl)){
 
        if(crouching){
 
            stopCrouching();
 
            return;
 
        }
 
        if(!crouching)
 
             crouch();
 
    }
 
 
 
    // crouch with smoothing
 
    if(crouching){
 
        if(mainCamera.transform.localPosition.y > crouchingHeight){
 
            if(mainCamera.transform.localPosition.y - (crouchHeight*Time.deltaTime*8) < crouchingHeight){
 
                mainCamera.transform.localPosition.y = crouchingHeight;
 
            } else {
 
                mainCamera.transform.localPosition.y -= crouchHeight*Time.deltaTime*8;
 
            }
 
        }
 
       } else {
 
        if(mainCamera.transform.localPosition.y < standingHeight){
 
            if(mainCamera.transform.localPosition.y + (crouchHeight*Time.deltaTime*8) > standingHeight){
 
                mainCamera.transform.localPosition.y = standingHeight;
 
            } else {
 
                mainCamera.transform.localPosition.y += crouchHeight*Time.deltaTime*8;
 
            }
 
            }
 
    }
 
    //set the max speed in the char motor;
 
     characterMotor.movement.maxForwardSpeed = speed;
 
}
 
 
 
// sets teh size of the collider to crouch size
 
	function crouch() {
 
        this.GetComponent(CharacterController).height -= crouchHeight;
 
        this.GetComponent(CharacterController).center -= Vector3(0,crouchHeight/2, 0);
 
        crouching = true;
 
 }
 
// resets the size of the collider to standing size  
 
 	function stopCrouching(){
 
        crouching = false;
 
        this.GetComponent(CharacterController).height += crouchHeight;
 
        this.GetComponent(CharacterController).center += Vector3(0,crouchHeight/2, 0);
 
}
	function OnGUI() {
		GUI.Box(new Rect(10, 50, fatigueBarLength, 20), fatigue + "/" + maxFatigue);
	}

First you need to figure out to access variables in other scripts. Here is a reference: Accessing Other Game Objects.

Next you have to decide if you want the crosshair to have knowledge of the player, or if you want the player to tell the crosshair what to display. Here is an example of the former (because it is easy, not because it is the ‘right’ way). You must make ‘crouching’ in your player script public for this code to work.

#pragma strict

var crosshairTexture : Texture2D;
var crosshairCrouchTexture : Texture2D;
var position : Rect; static
var OriginalOn = true;

var playerScript : PlayerScriptName;

function Start() {
// Don't need this line, if you drag and drop in the inspector
 playerScript = GameObject.Find("Player").GetComponent(PlayerScriptName);
}
 
function Update() {
    position = Rect((Screen.width - crosshairTexture.width) / 2, (Screen.height - crosshairTexture.height) / 2, crosshairTexture.width, crosshairTexture.height);
}
 
function OnGUI() {
    if(OriginalOn == true) {
       if (playerScript.crouching)
			GUI.DrawTexture(position, crosshairCrouchTexture);
       else
       		GUI.DrawTexture(position, crosshairTexture);
    }
}