Game object not true?

Game object comes up invalid or as unity's compiler says,"Assets/healthyhealth.js(15,3): BCE0005: Unknown identifier: 'gameObject'."

Heres the script

var mainCharacterHealth = 100;
var dead = false;

class health {
    var dead = false;

    function spawn () {
        //if you are dead goto position
        if (dead) {      
            gameObject.Find("MainCharacter").transform.position = Vector3(0,8,0);

    function OnControllerColliderHit ( hit : ControllerColliderHit ){
        //if you hit the designated object you will take 99 damage
            mainCharacterHealth -= 99;

In this instance, for `GameObject.Find()` should be capitalised. (Link to the scripting reference)

  GameObject.Find("MainCharacter").transform.position = Vector3(0,8,0);

Well, it seems you don't really know what you're doing here:

  1. Your script will create a class healthyhealth that is derrived from MonoBehaviour and can be attached to a GameObject.
  2. This class have only 2 variables `mainCharacterHealth` and `dead`, nothing else.
  3. You also create a class health that is derrived from System.Object and can not be attached to a gameobject. You can create an instance of that class in another class by using: `new health`
  4. Like Marowi said, Find() is a static method that don't needs a instance. Use the classname instead: `GameObject.Find()`
  5. You tried to use the property gameObject inside your health class. gameObject is only available in classes that derrives from Component like MonoBehaviour.
  6. The Unity event OnControllerColliderHit is only called on MonoBehaviour classes. You can of course name your function that way and call it manually from somewhere else.
  7. ControllerColliderHit is a classname. OnControllerColliderHit gets an instance of this class that contains information about the collision. `if(hit.ControllerColliderHit)` can't work and doesn't make any sense.
  8. You can't access `mainCharacterHealth` from within your health class. It's a seperate class.

In short: That script above doesn't make any sense.

stick a variable at the top called

var gameObject : GameObject;

then assign it in the inspector