BCE0019: 'GetComponent' is not a member of 'Object'.

I get this error when I tried to add score on death. how can I fix it? I’ll type in the enemy health script and the score script. Here we go.

#pragma strict
var thisObject : Transform;
var Health = 100;
var WillDrop : boolean = false;
var ObjectToDrop : GameObject; // means that you can use more than one objects
var otherObj = new Array();
var isDead : boolean = false;

function Start()
{
WillDrop = Random.value < 0.10; //Dropchance of 10%
}
{
otherObj[0] = GameObject.FindGameObjectWithTag ("Score");
}
function ApplyDammage (TheDammage : int)
{
	Health -= TheDammage;
	
	if(Health <= 0)
	{
		isDead = true;
	}
}

function Dead()
{
  if(WillDrop == true) {
        var obj : GameObject = ObjectToDrop[Random.Range(0,   ObjectToDrop.length)]; //Randomize a prefab to drop between   Medkit, ammobox and AllInOne kit  
        var pos: Transform = thisObject;
        Instantiate(obj, pos.position, pos.rotation); //Spawn prefabs
        Destroy (gameObject);
 }
 
    if (WillDrop == false) {
        Destroy (gameObject);
    }
    
}

function Score()
{
otherObj[0].GetComponent(ScoreSystem).curScore += 10;
}


function Update()
{
if(isDead == true)
	{
	Score();
	Dead();
	}
}

#pragma strict

var Score = 0;
var curScore = 0;
var Style : GUIStyle;

function Update () {

if (curScore > Score)
{
Score++;
}
if (Score > curScore)
{
Score = curScore;
}
}

function OnGUI()
{
GUI.Box(Rect(0,0,100,25), Score.ToString(), Style);
}

To all that answered this question with an advice to use a different GetComponent version, have you actually read the error in the title? If you get an error that “something” is not a member of “somethingElse” that means that “somethingElse” is the problem.

The problem here is that your otherObj variable is of type Array. The Array class is a container class which stores objects without their type. Every item in that collection is stored as System.Object. When you access an element you would need to cast it back to the actual type.

However it’s usually better to not use the Array class at all. Either use a built-in array or if the size of your collection will change a lot at runtime, use a generic List. See the Which_Kind_Of_Array_Or_Collection_Should_I_Use wiki page.

you can do it like

otherObj[0].GetComponent.<ScoreSystem>().curScore += 10;

GetComponent returns an object. You need to cast the result to a ScoreSystem before accessing the curScore member (or, better yet, use the generic version of GetComponent).