Wierd Error (UnityScript)

Firstly, I’m a newbie at scripting, and I’m sorry about my capitalization and indentation style. I’m experimenting with a few different ways that my rogue-like’s game manager could work. It’d take me too long to explain everything, especially since I type very slowly, so I have comments all around the script for important info. It is probably very unoptimized, but optimization isn’t the goal right now.

As of now, the game manager’s job is to get the ‘Speed’ var of every object tagged “monster”, and sort it out. The error is on line 48, and it’s telling me to insert a semi-colon.

#pragma strict

var Location = "GuardianForest"; //Ignore this.
var TheMonsters : GameObject[];
var SpeedOne : int[]; //The array that stores all monster speeds for sorting.
var SpeedTwo : int[]; //I probably don't need this, so you can ignore this too.
var Active = true;

var MonsterOne = "Absent"; //Stores all the monster names.
var MonsterTwo = "Absent";
var MonsterThree = "Absent";
var MonsterFour = "Absent";
var MonsterFive = "Absent";
var MonsterSix = "Absent";


function Start ()
{
    TheMonsters = GameObject.FindGameObjectsWithTag("Monster"); //Getting and storing monster names.
       
    MonsterOne = (TheMonsters[0].name);
   
    if (MonsterTwo != "Absent")
    {
        MonsterTwo = (TheMonsters[1].name);
    }
    if (MonsterThree != "Absent")
    {
        MonsterThree = (TheMonsters[2].name);
    }
    if (MonsterFour != "Absent")
    {
        MonsterFour = (TheMonsters[3].name);
    }
    if (MonsterFive != "Absent")
    {
        MonsterFive = (TheMonsters[4].name);
    }
    if (MonsterSix != "Absent")
    {
        MonsterSix = (TheMonsters[5].name);
    }
   
    var SpeedFinder : int[];
    gameObject.GetComponent(Monster_Template);
    SpeedFinder[0] = int Monster_Template.Speed;
    Debug.Log(SpeedFinder);
    SpeedOne[0] = SpeedFinder.Speed;
    Debug.Log(SpeedFinder);
    Debug.Log(SpeedOne[0]);

   

    if (Location == "GuardianForest") //This is irrelevant to the problem, completely (I think).
    {
        print ("Yes");
    }
}

function Update ()
{

}

Now here is the other script that goes with it. Alone, it serves it’s purpose perfectly (that is, until I need to add more to it). It is the script that every monster, player or AI, will have. There will ofcourse be some differences between player and AI variants, but that’s not to worry about. I’m merely saying this now to prevent irrelevant questions.

#pragma strict

//All names are typed with capital letters

var Health = 1000;
var IAttack = 1000;
var IDefense = 1000;
var PAttack = 1000;
var PDefense = 1000;
var EAttack = 1000;
var EDefense = 1000;
var Speed = 1000;
private var HealthLeft = 1000;
var Element = "None";
private var Turn = false;
var W = false;
var A = false;
var S = false;
var D = false;

function Start ()
{
   
}
function Update ()
{
    if(Input.GetKeyDown(KeyCode.W))
    {
        W = true;
        A = false;
        S = false;
        D = false;
    }

   
    //W
    //A
   
    else if(Input.GetKeyDown(KeyCode.A))
    {
        W = false;
        A = true;
        S = false;
        D = false;
    }
   
   
    //A
    //S
   
    else if(Input.GetKeyDown(KeyCode.S))
    {
        W = false;
        A = false;
        S = true;
        D = false;
    }
   
   
    //S
    //D
   
    else if(Input.GetKeyDown(KeyCode.D))
    {
        W = false;
        A = false;
        S = false;
        D = true;
    }
   
}

Like I said, very unoptimized. If you’d like to suggest a better way to make this script, feel free, but I plan to find better ways later on anyway. I just wanna know what’s up with that error.

You have

var SpeedFinder :int[];

So

SpeedFinder.Speed

is not something that exists.

–Eric

I probably should have mentioned I’ve been experimenting with that error line a lot. As you can probably tell from lines 44-48, I’m trying to get my the ‘Speed’ variable from my other script. Nothing has worked so far. Every attempt has given me some sort of error.

Use GetComponent to get variables from other scripts.

–Eric

Well, I’m having trouble with the variables in the array, but at least I know about the error now, so thanks for your help. I’m probably just gonna use enums.