Getcomponent through tag and findgameobject with tag and do a function but somehow gives errors (It's hard to explain)

As above it’s hard to explain. As well as I know it’s only one object that’s tagged with “player” and “firingpoint”
So I get this error that says:

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

and here’s my code
#pragma strict
var isMedkit : boolean;
var isAmmo : boolean;
var otherObj1;
var otherObj2;

function Start()
otherObj2 = GameObject.FindGameObjectsWithTag ("Player");
otherObj1 = GameObject.FindGameObjectsWithTag ("FiringPoint");

function OnTriggerEnter (other : Collider) {
 if (other.gameObject.tag == "Player")
if(isAmmo == true){
otherObj1.GetComponent(Thunderbolt).magsLeft += 5;
if (isMedkit == true){

otherObj2.GetComponent(Health).health = 100;

You are using GameObject.FindGameObjectsWithTag which returns an array of game objects.

Even though there is one game object tagged player you still get your ‘otherObj1’ and ‘otherObj2’ as an array because Unity will create an array of game objects to store the result of GameObject.FindGameObjectsWithTag.

So you have to access it as otherObj1[0], considering there is only one element in your array which you want to access.


use GameObject.FindGameObjectWithTag if you are to use it to find and store only one game object via tag.