title: How do I add the GameObject to my script?
body: <p>So I'm writing a script for respawning objects for a 2d game on unity, however whenever i try to call the object that is to respawn, it says that the object is either a method or statement. I feel like I've made a mistake somewhere. Please help correct me where im wrong. This is the code:</p>
  <pre><code>    using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
  
  
      public GameObject spike;
      public class Spikegenerator: MonoBehaviour
      {
      void Start()
      {
      for (int i = 0; i &lt; 10; i++)
      {
          float spawnY = Random.Range
              (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).y, 
      Camera.main.ScreenToWorldPoint(new Vector2(0, Screen.height)).y);
          float spawnX = Random.Range
              (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).x, 
      Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0)).x);
  
          Vector2 spawnPosition = new Vector2(spawnX, spawnY);
          Instantiate(spike, spawnPosition, Quaternion.identity);
      // the gameobject is 'spike'
      }
      }
  
      }'''
  </code></pre>