haveing trouble with for.

I am working on something and i cant figure out how to use for statements.

I usually make a statement like.

var Clones : GameObject[];
var X = 1;
function update () {
   if (X == 1) {
       for (var Bullet in Clones) {
            if (Bullet.name == "BulletUp") {
                Bullet.tranform.position += Vector3.up;

it keeps giveing me this error. 

NullReferenceException: Object reference not set to an instance of an object
Controls.Update () (at Assets/Scripts/Controls.js:79)

Usually you need to use the "var" keyword, but i don't use UnityScript very often. Also a gameobject don't have a member "transition", it's called "transform". And of course what has been mentioned in the comments above: Update with capital U.

function Update () {
    if (X == 1) {
        for (var Bullet in Clones) {
            if (Bullet.name == "BulletUp") {
                Bullet.transform.position += Vector3.up;


Next time when you ask a question, mention the actual problem.

The NullReferenceException has nothing to do with your for-loop. You just have an empty "slot" in your array. The for loop will iterate over every item in the array. If you haven't set every item to a GameObject instance you will get a null-ref-exception when you try to work with the item.

Um, slightly confused what your asking but if its ‘How do you use for in a script?’ question then this is a script on the unity script reference page:

// Print the name of the closest enemy

// Find the name of the closest enemy
function FindClosestEnemy () : GameObject {
    // Find all game objects with tag Enemy
    var gos : GameObject[];
    gos = GameObject.FindGameObjectsWithTag("Enemy"); 
    var closest : GameObject; 
    var distance = Mathf.Infinity; 
    var position = transform.position; 
    // Iterate through them and find the closest one
    for (var go : GameObject in gos)  { 
        var diff = (go.transform.position - position);
        var curDistance = diff.sqrMagnitude; 
        if (curDistance < distance) { 
            closest = go; 
            distance = curDistance; 
    return closest;    

basically ‘for’ is used to do a set of commands for every object of a type, in this case they want to find the closest object with a certain tag… first they make an array of objects with that tag and then using for, they look at each object in that array and check if its closer than the last one they checked

object1 distance is less than infinity, if yes object1 distance = shortestdistance and object1 = target

object2 distance is less than object1 distance, if yes object 2 distance = shortestdistance and object2 = target

and so on, ^ thats what they mean by iterate, it just goes through every object in the array

your script is more or less right, capital U for update, transform not transition… but that might help you understand what its doing :confused: