How would I make a object spawn only once.

I am quite new to Unity and am making a 2D game where I need to spawn in objects into the scene. I am trying to make it so every 500 on the ball timer it will spawn one ball. But what its doing is once it reaches 500 it spawns hundreds of balls constantly every second and I need to know how to spawn only one every 500 on the ball timer.

#pragma strict
var Timer : int = 0;
var Text : UnityEngine.UI.Text;
var Ball : GameObject;
var ballTimer : int = 0;

function Start () {
	
	var randomNumber = Random.Range(0, 2);
	if (randomNumber <= 0.5){
		GetComponent.<Rigidbody2D>().AddForce (new Vector2 (30, -30));
		}
	else{
	GetComponent.<Rigidbody2D>().AddForce (new Vector2 (-30, 30));
	}

}

function SpawnBall()
{
	Instantiate(Ball, new Vector2(0,0), Quaternion.identity);
}

function Update()
{
ballTimer += 1;
Timer += 1;
Text.text = "Score: " + Timer; 

	if (ballTimer > 500){
	SpawnBall();
	ballTimer = 0;
	}
}

function OnCollisionEnter2D (colInfo : Collision2D) {
	if (colInfo.collider.tag == "Player") {
	//GUI Game Over
	}
}

It looks to me like you have a single script performing two separate roles. One is to program the behaviour of the ball objects. And the other is to spawn in balls at an interval. The bug here is caused by the spawning behaviour feeding back and creating additional balls.

To fix this you should probably split the script into two and assign them to two different objects. One is the Ball and ball behaviour. The other is a spawner and the spawning / scoring behaviour. The spawner object can be an empty object, it just needs to hold the spawning script.

The spawner object just sits there and invisibly ticks up until it’s time to spawn a new ball. And then the new ball just runs its behaviour:

Ball.js

#pragma strict

function Start () {

	var randomNumber = Random.Range(0, 2);
	if (randomNumber <= 0.5){
		GetComponent.<Rigidbody2D>().AddForce (new Vector2 (30, -30));
	}
	else{
		GetComponent.<Rigidbody2D>().AddForce (new Vector2 (-30, 30));
	}
}

function OnCollisionEnter2D (colInfo : Collision2D) {
	if (colInfo.collider.tag == "Player") {
		//GUI Game Over
	}
}

Spawner.js

#pragma strict
var Timer : int = 0;
var Text : UnityEngine.UI.Text;
var Ball : GameObject;
var ballTimer : int = 0;

function SpawnBall()
{
	Instantiate(Ball, new Vector2(0,0), Quaternion.identity);
}

function Update()
{
	ballTimer += 1;
	Timer += 1;
	Text.text = "Score: " + Timer;

	if (ballTimer > 500){
		SpawnBall();
		ballTimer = 0;
	}
}

Make the ballTimer a float value.
Add with deltaTime to it:

ballTimer += 1 * Time.deltaTime;

And add a boolean just to be sure the Spawn function is never executed twice.

if (ballTimer >= 500 && !ballSpawned){
   ballSpawned = true;
   SpawnBall();
   ballTimer = 0;
}

Also make sure you unset the boolean in the Spawn function:

 function SpawnBall(){
     Instantiate(Ball, new Vector2(0,0), Quaternion.identity);
     yield WaitForSeconds(1);
     ballSpawned = false;
 }

I would also like to suggest to move the Update function below the Start function, excecution order and so on…