i am getting the following error Assets/Coin.js(10,10): BCE0051: Operator ‘+’ cannot be used with a left hand side of type ‘MenuShopSystem’ and a right hand side of type ‘int’. I got the variable from the shop script
Coin Script
#pragma strict
var Money : MenuShopSystem ;
function Start () {
}
function OnCollisionEnter ( )
{
Money += 100;
GameObject.Destroy ( gameObject ) ;
}
Shop Script if it helps
#pragma strict
//add this script to any gameObject you want//
//paste this to add more items to youre shop:
// if(GUI.Button(Rect(Screen.width/2,Screen.height/2,150,150), Item)){
// if(Money >= 200){
// Money -= 200;
// }else{
// Money -=0;
// }
// }
// GUI.Button(Rect(Screen.width/2+150,Screen.height/2,150,150), "Buy: 200");
//variables----------------------------------------
var ShowShop = false;
var CoinTexture : Texture;
public var Money :int=0;
var skin : GUISkin;
var AddButton = false;
//Items:
//to add more items just copy this variable and add the item name;
var Item : Texture;
var Item2 :Texture;
var Item3 :Texture;
//code----------------------------------------
function Start () {}
function Update () {
if(Money <= 0){
Money = 0;
}
}
function OnGUI(){
GUI.skin = skin;
if(ShowShop ==true){
//money{********************-------------------------------------------------------------**************************
GUI.Button(Rect(Screen.width/60,Screen.height/60 ,50,50), CoinTexture);
GUI.Button(Rect(Screen.width/60+50,Screen.height/60 ,70,50), ""+Money);
if(AddButton ==true){
if(GUI.Button(Rect(Screen.width/60+120,Screen.height/60 ,70,50), "Add")){
Money += 100;
}
}
//money}***********************-------------------------------------------------------------------*****************************
//Items(Shop){
if(GUI.Button(Rect(Screen.width/2,Screen.height/2,150,150), Item)){
if(Money >= 200){
Money -= 200;
}else{
Money -=0;
}
}
GUI.Button(Rect(Screen.width/2+150,Screen.height/2,150,150), "Buy: 200");
if(GUI.Button(Rect(Screen.width/2,Screen.height/2- -150,150,150), Item2)){
if(Money >= 150){
Money -= 150;
}else{
Money -=0;
}
}
GUI.Button(Rect(Screen.width/2+150,Screen.height/2- -150,150,150), "Buy: 150");
if(GUI.Button(Rect(Screen.width/2,Screen.height/2- 150,150,150), Item3)){
if(Money >= 500){
Money -= 500;
}else{
Money -=0;
}
}
GUI.Button(Rect(Screen.width/2+150,Screen.height/2- 150,150,150), "Buy: 500");
//Items(Shop)}
}
}//OnGUI End////////////////////////////////////