Trying to link a variable between two gameObjects

I’m making a cookie clicker like game and I have just one script and would like to keep it that way. What I’m trying to do is if you have enough “doges” to buy “wowes” you’ll buy it but a problem I’m encountering is that I click the doge to get the doges and then I try to buy one wowe but it seems it’s two seperate variables
Some code that may help solve this:

var IsDoge=false;
var IsWowe=false;
var doges=0;
var wowes=0;
var wowesCost=10;
var guiDoge : GUIText;
var guiWowesBuy : GUIText;

function Start() {
	guiDoge.text= "Doges: 0";
	guiWowesBuy.text= "Wowes: 0 BUY = 10 Doges";
}


function OnMouseUp() {
	if (IsDoge==true) {
		doges += 1;
		guiDoge.text = "Doges: " + doges;
		Debug.Log(doges);
	}
	else if (IsWowe==true) {
		if (doges > wowesCost) {
			doges -= wowesCost;
			wowes += 1;
			wowesCost = wowesCost * 1.5;
			guiWowesBuy.text = "Wowes: " + wowes + " BUY = " + wowesCost + " Doges";
		}
	}
};

Try changing:

var doges=0;
var wowes=0;

to

static var doges=0;
static var wowes=0;

It seems like you’ve got two GameObjects each with the same script, but each GameObject still maintains its own variables unique to that instance. By declaring the variables to be static, you can access them in all GameObjects that have the attached script.