Creating flashlight

Hey I was wondering if someone out there will help me out creating a script to pick up a flashlight and turn it on (and vice versa). I'm more of an artist and not a programmer/coder so a basic start of the script to help me learn would be great.

-Joseph C

Use this :).

var light1 : Light;

function Update () {
if (Input.GetKeyDown(KeyCode.Q)){
light1.enabled = !light1.enabled;
}
}

Change the keyCode to whatever you need, and just assign a light in the editor.

EDIT: For the pickup, put the flashlight object as a child to your main camera, making sure you can see it etc. Then put a model on the floor of the flashlight. Give it a trigger and apply this script:

var ThisObj : GameObject;
var PlayerFlashLight : GameObject;

function Start (){
PlayerFlashLight.active = false;
)

function OnTriggerStay() {

if(Input.GetButtonDown("Pickup")){

//Enable the player's flashlight object
PlayerFlashLight.active = true;
//deactivate this object
ThisObj.active = false;

   }
}

Now attach this script to the trigger collider that is a child of the flashlight on the floor. Set ThisObj as the parent flashlight, and set PlayerFlashLight as the players flashlight GameObject. Set up a new input called "Pickup", then run the game. Walk over to the torch/flashlight and press your pickup key, et voila! Pickup!