Enable/Disable Game Object With GUI Button

Hi folks,

I’m currently designing a car game and have hit a snag.

I’ve got several lights, all of the lights are attached to their own, seperate, empty gameobject.

What i’m planning to do, is have the ability for the lights to be switched on/off with the touch of a GUI button, this is for Android. By default, the lights are off.

I’ve tried a variety of scripts i’ve made, such as the one below:

var bluelight1: GameObject;

function Start () {
    bluelight1 = GameObject.Find("GameObject5");

function OnGUI () {

if(GUI.Button(Rect(120,450,100,20),"Lights On")){
    bluelight1.active = true;


Any ideas on this one please?



If bluelight is an emty game object with light component attached to it try with:

bluelight.light.enabled = true;