Saving Scripts to variables and MonoBehaviour

I have this code:

var enemyCount : int;
var turretCount : int;
var script : MonoBehaviour;
var win : boolean;

function Awake ()
{
    script = GetComponent("SpawnScript");
}

function Update ()
{
    if (!win)
    {
        enemyCount = script.enemyCount;
        turretCount = script.turretsAlive;

        if (enemyCount == 0 && turretCount == 0)
            win = true;
    }
}

function OnGUI()
{
    if (GUI.Button (new Rect(400,300,200,100),"Play Again?"))
        Application.LoadLevel(0);
}

Yet, when I try to save it, it says enemyCount and turretsAlive are not a part of MonoBehaviour. I don't get what I'm doing wrong.

You need to change

var script : MonoBehaviour;

to

var script : SpawnScript;

This answer covers the details. Basically, you told the code that the component you're retrieving is a MonoBehaviour when in reality its a script.