help!! drop spawner BCE0005: Unknown identifier: 'i'

I am creating a game for android in unity 5 and I need to use this script , I used formerly with Unity 4.5 but now does not work

var spawnPoints : Transform[];  // Array of spawn points to be used.
var Prefabs : GameObject[]; // Array of different Enemies that are used.
var amount = 20;  // Total number of enemies to spawn.
var yieldTimeMin = 2;  // Minimum amount of time before spawning enemies randomly.
var yieldTimeMax = 5;  // Don't exceed this amount of time between spawning enemies randomly.

function Start(){
    Spawn();
}

function Spawn(){
   for (i=0; i<amount; i++){
      yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));

      var obj : GameObject = Prefabs[Random.Range(0, Prefabs.length)];
      var pos: Transform = spawnPoints[Random.Range(0, spawnPoints.length)];

      Instantiate(obj, pos.position, pos.rotation);
    }
}

I tried everything but I managed to solve the problem

please guys help me

What’s the full error message on the console?

You’ve forgotten to declare the variable ‘i’ in the loop.
Try

(var i=0; i<amount; i++){

or:

(int i=0; i<amount; i++){

instead of

(i=0; i<amount; i++){

the full error message say:

assets/dropspawner.js(13,9): BCE0005: Unknown identifier: ‘i’.

dont work man :frowning:

The most common, least helpful phrase on the forums. “Doesn’t work” doesn’t say anything. Different error message? Same error message? Also, there were two suggestions given there, which one did you try? or did you try both?

(“var i” is absolutely and exactly the solution, btw, so if you tried that and you’re still getting the same error…maybe you forgot to hit save? Don’t know what else to tell you)

I am new to unity and not used very well could you help me create the script that is to say that I did not know how to correct the problem with your suggestion

Exactly what @Suddoha suggested. The first suggestion, in particular (the second one would only work in C#). I honestly don’t think I can make it any clearer than he did.

i use var i and the message say:

Assets/dropspawner.js(1,2): BCE0043: unexpected token: var and other look the pic

i use this script wih your modification

(var i=0; i<amount; i++){
var spawnPoints : Transform[];  // Array of spawn points to be used.
var Prefabs : GameObject[]; // Array of different Enemies that are used.
var amount = 20;  // Total number of enemies to spawn.
var yieldTimeMin = 2;  // Minimum amount of time before spawning enemies randomly.
var yieldTimeMax = 5;  // Don't exceed this amount of time between spawning enemies randomly.

function Start(){
    Spawn();
}

function Spawn(){
   for (i=0; i<amount; i++){
      yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax)); 

      var obj : GameObject = Prefabs[Random.Range(0, Prefabs.length)];
      var pos: Transform = spawnPoints[Random.Range(0, spawnPoints.length)];

      Instantiate(obj, pos.position, pos.rotation);
    }
}

2388926--162694--mistake.png

and sorry for my english jaja i live in Panama and speak in spanish

Where’s your “for” at the start of your (var i = 0…) part at the beginning of your code?

And where’s your brackets? The first 6 lines of your code is meaningless and error-prone.

Sorry, you could modify my script? active command would try

the START be in the 8 line, the function Start for the Script

@asperatology

i wanna help to other gays with this problem because im new in this and
I know how hard it is to start using a new program

Do you know how to program? As in, type codes? If you can’t, start here.

a little, I 'm studying in the university
I’m in second half

CS, ECE, RBE, MIS, anything? Anything related to computers?

Go here instead.

thank you man,

and sure, but you think you can fix the script

its a simple script i need spawner objets

i have 3 months with this proyect and i wanna to learn

Remove Line 1~6, and Line 14 in the code given above.