3.5 change?

I’m having an error that won’t allow me to use this function. the error says :
Assets/EnemyScript.js(17,18): BCE0019: ‘CurrentElement’ is not a member of ‘UnityEngine.GameObject’.

I’m a little confused as to the cause of this?

var WorldElement:GameObject;
var WorldElementInfo:GameObject;

function RelinquishElement()
{
WorldElement=GameObject.FindWithTag("WorldElement");
WorldElementInfo=WorldElement.GetComponent("WorldElementInfo");
WorldElementInfo.CurrentElement+=TrappedElement;
}

My guess would be that worldElementInfo is of type GameObject. You probably want it to be of type WorldElementInfo (on line 2), as that is the type you are retrieving from worldElement.

It’s not a 3.5 change. It would potentially work if the WorldElementInfo variable was a Component rather than a GameObject. Presumably you want it to be of type WorldElementInfo, although that’s the name you gave to your variable. This is why you need to use lowercase letters for naming variables, and uppercase for classes and functions. Also, you want GetComponent to return WorldElementInfo rather than Component. It will do that if you write GetComponent(WorldElementInfo). If you use a string, it doesn’t know what the type is, so it can only return Component. This is why you should basically never use strings in GetComponent, except for the one exception described in the docs (namely, accessing components when the type isn’t available, but that’s pretty rare).