ERROR: BCE0019: 'enabled' is not a member of 'UnityEngine.GameObject'.

Ok,
So in my game the main character has to use matches to light a fire.
Here is my script:

var batterySound : AudioClip;
private static var batteryPower : float = 10;

var Matches : GameObject;
var Fire : GameObject;

private var hasPlayed = false;

function Start()

{
	gameObject.enabled = false;
}

function OnTriggerEnter (c : Collider)
{
	buttonInRange = true;

}

function OnTriggerExit (c : Collider)

{
	buttonInRange = false;

}

function OnGUI ()
	{
	if (buttonInRange == true)
		{

		if (Matches == false)

			{

			GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Use matches");
	
			}
		}

	}
function Update ()
{
	if (buttonInRange == true)
	{
		if (Input.GetKeyDown ("e"))
		{
			if(!hasPlayed)
			{
				AudioSource.PlayClipAtPoint(batterySound, transform.position);
				gameObject.enabled = false;
				hasPlayed = true;
			}
		}
		
	}
	
}

It all works fine except when I go to play it, I get the error
Assets/FireStart.js(46,44): BCE0019: ‘enabled’ is not a member of ‘UnityEngine.GameObject’.
in lines 15 and 55…
when I try to get rid of this error, the game plays but the fire is automatically on.
Just to recap, what I want is an empty fireplace and the character collects matches (this collection part works fine) and then when the player gets close enough to the fireplace it displays “use matches” (which also works perfectly) and when the player presses “E”, the fire will be lit (DOES NOT WORK)…
I have no idea what is wrong…
Thanks

Compilers usually don’t lie and when you check the documentation for GameObject, you’ll see that it doesn’t have a public variable “enabled”.

Try gameObject.SetActive(false);

However, if you’d call SetActive(false) in Start(), Update() would never get called. So i’m not sure if that’s what you actually want to do.

Try this: gameobject.SetActive(true); gameobject.SetActive(false);