How to make gameObject and GUI button invisible/visible?

I’m trying to use GUI buttons as switches between two lights; a flashlight, and the sun. I also want the buttons that operate the flashlight rotation to disappear when the sun is activated. However, I can’t get the flashlight and buttons to become invisible. Also the reset button, which is supposed to reset the flashlight’s position as well as the sliders, isn’t working properly; it resets the sliders without moving the flashlight.

var fLight: Light;
var sunLight: Light;
var flashlight: GameObject;
private var fon = false;
private var son = false;
var startPosition : Vector3;
var startRotation : Quaternion;
var vSliderValue: float = 0.0;
var hSliderValue: float = 0.0;
private var reset = false; // object resets if true;

function Start()
{
 fLight.light.intensity = .51;
 sunLight.light.intensity = 0;
 startPosition = transform.position;
    startRotation = transform.rotation;
}
function Update()
{
 if (fon) sunLight.light.intensity = 0;
 if (fon) fLight.light.intensity = .51;
 if (fon) flashlight.gameObject.active = true;
 if (son) fLight.light.intensity = 0;
 if (son) sunLight.light.intensity = .5;
 if (son) flashlight.gameObject.active = false;
 if (son) reset.active = false;
 if (son) hSliderValue.active = false;
 if (son) vSliderValue.active = false;
 if (vSliderValue) flashlight.transform.rotation.eulerAngles.x = vSliderValue;
 if (hSliderValue) flashlight.transform.rotation.eulerAngles.z = hSliderValue;
 if (reset) transform.position = startPosition;
    if (reset) transform.rotation = startRotation;
    if (reset) vSliderValue = 0;
    if (reset) hSliderValue = 0;
}

function OnGUI()
{
 vSliderValue = GUI.VerticalSlider(Rect(10,20,10,100), vSliderValue, -50, 50);
    hSliderValue = GUI.HorizontalSlider(Rect(20,10,100,10), hSliderValue, -50, 50);
    reset = GUI.Button(Rect(40,40,50,50), "Reset");
 fon = GUI.Button(Rect(900,10,100,100), "Flashlight");
 son = GUI.Button(Rect(900,120,100,100), "Sun Light");
}

Ok so there is quite a lot wrong with your style of coding here - you should not be doing anything in Update to start with and you should make all of your ifs multi line using { and }.

You can have all of your if logic in the OnGUI -

fon = GUI.Button(Rect(900,10,100,100). "Flashlight");
if(fon) {
     sunLight.light.intensity = 0;
     flight.light.intensity = 0.51;
    //etc etc
}

reset.active makes no sense. Add a #pragma strict to the top of your code to reveal some of the errors. I can’t see where you set reset to true in this code either.

I don’t know why I was completely unable to hide the flashlight in this scenario; instead, I moved it out of the camera’s view and back again (using transform) each time the ‘reset’ button is hit.