TeamFPSPlayerNode = game.teamPlayerList[t] as TeamFPSPlayerNode;
I’m assuming here that “TeamFPSPlayerNode” is a type – that it’s a class you’ve built, somewhere? Some people helpfully suggested that you should declare a variable and give it a name, like so:
TeamFPSPlayerNode go = game.teamPlayerList[t] as TeamFPSPlayerNode;
But this has another problem: UnityScript doesn’t declare variables in the same way that most “C family” languages do.
//C#
int x;
//UnityScript
var x : int;
You don’t actually have to provide a type, in UnityScript, if the compiler can infer which type you want:
//these two lines do the same thing
var x : int = 2;
var x = 2; //the compiler can tell up front that you want an integer
If you want to declare a variable and assign it later? Then you’ll need to specify a type. It’s possible to get into some interesting shenanigans, there, anyway. It’s always safer to specify a type, but it’s nice to know sometimes that you don’t always have to.
(C# has a similar feature using var, actually, but I notice a lot of people get confused by it.)
So, getting back to your script, we need to change the syntax used when declaring your variable:
var go = game.teamPlayerList[t] as TeamFPSPlayerNode;
Well it looks like all you are doing in the for loop is defining some object, so you need to have a variable in there like “go” to be the variable. You aren’t doing anything with this variable, so I assume after you get this fixed you’ll go on to doing something with that go variable.
function OnGUI()
{
if(conActive)
{
for(t = 0; t < game.teamPlayerList.Count; t++)
{
TeamFPSPlayerNode go = game.teamPlayerList[t] as TeamFPSPlayerNode;
}
}
}