Problem with code in js

Hi i’m new here and this is my problem :confused: :

Assets/skrypty/spawn.js(48,1): BCE0044: expecting }, found ‘’.

And code :

var player : GameObject;
var spawn : GameObject;

function Awake () 
{
if(Network.isClient || Network.isServer)
{
for (var go : GameObject in FindObjectsOfType(typeof(GameObject)))
{
gameObject.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
}
}
else
{
Application.LoadLevel("Assets/Destroyed_City_FREE/Scenes/menu");
}
}

function onGUI()
{
GUILayout.BeginArea(Rect(0,0,40,40));
GUILayout.BeginHorizontal();
if(GUILayout.Button("1"))
{
Network.Instantiate(player, spawn[1].transform.position, spawn[1].transform.rotation, 0);
}
if(GUILayout.Button("2"))
{
Network.Instantiate(player, spawn[2].transform.position, spawn[2].transform.rotation, 0);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if(GUILayout.Button("3"))
{
Network.Instantiate(player, spawn[3].transform.position, spawn[3].transform.rotation, 0);
}
if(GUILayout.Button("4"))
{
Network.Instantiate(player, spawn[4].transform.position, spawn[4].transform.rotation, 0);
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}

Between line 31 and 32 in your post, you need to close the if statement with a }

On another note, the OnGUI needs to be written as I wrote it. ie. with a capital letter “O”. Otherwise, it will not work.

Hope this helps :slight_smile:

add a " } " at the end

That was so easy. I didn’t see this. But i have another error :

(25,29): BCE0048: Type ‘UnityEngine.GameObject’ does not support slicing.