How to pass a variable from one script to another correctly.

I am having problems passing a variable from one script to another. I thought I have followed the support documentation and what I can find on here to the letter but obviously not. I know what I am missing out is probably obvious and simple but can not for the life of me see it.

This script is supposed to pass the RespY value and is attached to an empty object. The idea being that this script can be altered to speed up or slow down the respiration rate and also the depth of breathing:

var TimeToNextBreathe: float = 4;
var RespirationDuration: float = 3;
var RespirationMaxAmplitude: float = 10;
static var RespY: float;
private var startTime : float;

function Start () {

    startTime = Time.time;

}
function Update () {

    RespY = Mathfx.Hermite(0, 10, (Time.time - startTime) / RespirationDuration);
    yield WaitForSeconds(TimeToNextBreathe - RespirationDuration);

}

This script then takes that value and plots the Y value - the x value is constant as it is a display like an ECG. The object this is attached to is a pre-fab trailrender hence the destruction when it jumps back to the start of the simulated monitor display. This may seems a complicated way of doing it but it is the only way I can see when my next step is to form heart waves based upon their composite parts. (yes Unity Trauma Centre is on the way).

var RespirationTrace: Transform;
private var sX: float = 0;
private var sY: float = 0;

function Start() {

    yield WaitForSeconds (30);
    Destroy (gameObject);

}

function Breathe() {

    sY = RespirationController.RespY;
    transform.position = Vector3(sX, sY, 0);
    sX = sX + (20 * Time.deltaTime);

}

Any help would be gratefully received and highly appreciated.

Your first script is more or less doing nothing because `start()` and `update()` are not being called by Unity since the function names are wrong. Try changing the names of the functions from `start()` to `Start()` and `update()` to `Update()`. You also have to remove this line from the `Update()`, because it can't be a coroutine:

yield WaitForSeconds(TimeToNextBreathe - RespirationDuration);

Edit: Here is an example on how you can achieve a delay every 2 seconds:

private var timer: float = 0.0;
private var breathing: boolean = false;

function Start() {
    timer = 0.0;
    breathing = true;
} 

function Update () {
    if (breathing) {
        timer += Time.deltaTime;
    } 

    if (timer >= 2) {
        //Do something useful every 2 seconds (like take a breath)  
        timer = 0.0;
    }
}