Unexpected symbol = and ( in class stacture or interface member declairation

Hi, I’m trying to create buttons witch toggle on and of scripts found in the same gameobject
titles missioncontroll. all scripts needed are in and spelt the same as the .cs
using UnityEngine;
using System.Collections;

public class normalg : MonoBehaviour {
	       
	spaceportstore  = GetComponent<Spaceport>();
	 SpageGoldPurchase = GetComponent<SPaceGold>();




	// Buttons to toggel on adn of store and to purchase SPacegold to your acount.

	void OnGUI () {
		// Make a background box
		GUI.Box(new Rect(0,0,Screen.width,Screen.height), "EarthAlianceOnline");
		GUI.Box(new Rect(0,0,400,10), "Acount");

		
		// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
		if(GUI.Button (new Rect(450,40,80,30), "Play")) {
			Application.LoadLevel(1);
		}
		
		// Make the second button.
		if(GUI.Button(new Rect(100,70,80,20), "SpacePort")) {
			spaceportstore.enabled = !spaceportstore.enabled; //toggle on if of toggle of if on.
		}
		// Make the second button.
		if(GUI.Button(new Rect(200,70,80,20), "SpaceGold")) {
			SpageGoldPurchase.enabled = !SpageGoldPurchase.enabled; //toggle on if of toggle of if on.
		}
	}
}

There are 2 obvious problems with your first 2 lines.

First, the variables need to be declared. The compiler has no idea what kinds of thing spaceportstore and SpageGoldPurchase are.

Secondly, you are trying to initialise them in the wrong place. You can’t do it on declaration, the functions Start() and Awake() are provided for this sort of thing.

So that should give you something like this…

SpacePort spaceportstore  = null;
SPaceGold SpageGoldPurchase = null;

void Start()
{
    spaceportstore  = GetComponent<Spaceport>();
    SpageGoldPurchase = GetComponent<SPaceGold>();
}

An alternative would be to set them the first time you use them (this is called ‘lazy initialisation’).
For example at the top of your OnGUI() function you could have

if (spaceportstore == null)
{   
   spaceportstore  = GetComponent<Spaceport>();
}