No appropriate version of 'UnityEngine.Object.Instantiate'

I’m having a problem with this script:

public var enemySpawnLimit : int;               // Sets the number of Enemys you wanna spawn at this location
public var radiusmax: float;                    // The radius maximum.

private var radiusx=0.0;                        // x co-ordinate
private var radiusy=0.0;                        // y co-ordinate
private var radiusz=0.0;                        // z co-ordinate

function Start () {

//  for (var y = 0; y < enemySpawnLimit; y++) {									         // If you wanna spawn the Enemys upwards, say for flying
for (var x = 0; x < enemySpawnLimit; x++) {                                			     // this code is to cycle through spawning until X amount of enemys has arrived 
radiusx=Random.Range(0.0,radiusmax);                                                     // Everytime A cube is spawned a it spawns at a random x,y,z location

            Instantiate(enemy, Vector3 (radiusx, radiusy, radiusz), Quaternion.identity);       // the spawning script bit

function Update () {


Not sure how to fix it. as I get this error.

Assets/Scripts/enemy.js(22,24): BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Type, UnityEngine.Vector3, UnityEngine.Quaternion)' was found.

This line:

Instantiate(enemy, Vector3 (radiusx, radiusy, radiusz), Quaternion.identity);

Judging by the compiler error, enemy is the name of a script you wrote, not a variable in the code you posted.

Instantiate() is usually used to spawn a prefab instance. Perhaps you could create an inspector variable, then use that? There are plenty of tutorials around the net, but here’s a quick example:

public var enemyPrefab : GameObject;


//in some function
Instantiate(enemyPrefab, someVector, someRotation);