enable/disable specific components

how do i enable and disable specific components on a gameobject with a script?

In order to be able to "disable" something, it generally must derive from Behaviour. (Renderer is a notable exception). If you see a checkbox in the Inspector, you can enable or disable it. There are a bunch of shortcuts. For those that have a checkbox, you can do it like this:

camera.enabled = false;

For other behaviours, like your own scripts, you can do it like this, in UnityScript:

GetComponent(MyScript).enabled = false;

or in C#:

GetComponent<MyScript>().enabled = true;

Way to disable all scripts on object (C#):

MonoBehaviour[] scriptComponents = someObject.GetComponents<MonoBehaviour>();	
foreach(MonoBehaviour script in scriptComponents) {
    script.enabled = false;

My script says Assets/_Scripts/EnterExit.js(24,71): BCE0019: ‘enabled’ is not a member of ‘UnityEngine.Component’. please help since I am only a modeler :slight_smile: