Battery Pickup Regeneration

I’m trying to make it so that whenever my player collides with a battery on the floor it dissapears and then fills up my flashlight life, I have a script for my flashlight to make it drain over time and fade out but I have been trying to do this battery pickup for a while now and just cant get it to work, I’ve tried so many scripts and im not very good with unity which is why im learning, help would be very much appreciated, here is my flashlight script code with the Javascript name (Player_Toggle_Flashlight)

The problem that I get with most scripts I use is that my player will get the option to press ‘E’ over the betteries but when I press ‘E’ it will go off the ‘game’ back into ‘scene’ mode with my player stood over the battery with it under his feet, this keeps occuring, it will just make the unity go off the game scene and the battery wont destroy.

#pragma strict
 
//Variables START
 
//Light Source && Battery Life
var flashlightLightSource : Light;
var lightOn : boolean = true;
var lightDrain : float = 0.1;
var batteryLife : float = 0.0;
var maxBatteryLife : float = 2.0;
 
//Sound Clips
var soundTurnOn : AudioClip;
var soundTurnOff : AudioClip;
 
//Variables END
 
function Start()
{
        batteryLife = maxBatteryLife;
        flashlightLightSource = GetComponent(Light);
}
 
function Update()
{
        if(lightOn && batteryLife >= 0)
        {
                batteryLife -= Time.deltaTime * lightDrain;
        }
       
        flashlightLightSource.light.intensity = batteryLife;
       
        if(batteryLife <= 0)
        {
                batteryLife = 0;
                lightOn = false;
        }
       
        if(Input.GetKeyUp(KeyCode.F))
        {
                toggleFlashlight();
                toggleFlashlightSFX();
               
                if(lightOn)
                {
                        lightOn = false;
                }
                else if(!lightOn && batteryLife >= 0)
                {
                        lightOn = true;
                }
        }
}
 
function toggleFlashlight()
{
        if(lightOn)
        {
                flashlightLightSource.enabled = false;
        }
        else
        {
                flashlightLightSource.enabled = true;
        }
}
 
function toggleFlashlightSFX()
{
        if(flashlightLightSource.enabled)
        {
                audio.clip = soundTurnOn;
        }
        else
        {
                audio.clip = soundTurnOff;
        }
       
        audio.Play();
}
 
@script RequireComponent(AudioSource)

function OnTriggerEnter(other : Collider)
{
if(other.collider.transform.CompareTag(“Battery”) == true)
{
batteryLife = maxBatteryLife;
Destroy(other.transform.gameObject);
}
}

Now you only need a battery gameObject that has a collider (box collider should suffice) with it’s tag set to Battery or whatever, and the collider set to Is Trigger = true. Also, the player object needs not only a collider but also a rigidbody.

which tag do i add to my battery, I added a cube with box collider on and trigger, this is tagged as ‘Battery’, the battery object itself hasn’t got a tag and is marked untagged (grouped cube and battery together)Ingame I have placed the cube over my battery object with the mesh renderer off but box collider and trigger on, the battery has mesh renderer on and mesh collider and trigger off

I have made a rigid body under my graphics which is linked to my player (First person controller) also, I know some of the tagging and stuff if probably wrong but I have been played around with the tags, colliders and various different scripts etc for 2 days and cant get it too work :S. Its still coming up ‘unknown identifier maxBatteryLife’ which is puzzling as the variable is definitely that :S

In the project menu at the bottom my battery is named ‘Battery’, does this make a difference? im talking about the object which shows up after you import it from Maya and when you click on it it comes up with ‘generate colliders’ etc