Is not a Member of Collisions

Hi, I’m new to programming and I’m using Javascript, I’m having a problem with the script though.

GRENADE_AMMO’ is not a member of ‘Collisions’.

"Collisions = Collisions.GRENADE_AMMO --;"
"Collisions.GRENADE_AMMO += 8;"

These are linked to the error i think.

Can anyone help me please?

enter code here

var Collisions;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == “CrateGrenades”)

{
//destroy the ammobox
Destroy(hit.gameObject);

Collisions = GRENADE_AMMO --;

//add ammo to inventory
Collisions.GRENADE_AMMO += 8;
}

}

}

How have you defined Collisions? Because there is no GRENADE_AMMO member variable in it. And you are setting Collisions to Collisions.GRENADE_AMMO which is strange. Can you post more code?

"Well, there are two peices of code, not very effietient of me but here’s a piece.
I’m following a tutorial btw.

//create the perfab
var Crate = Instantiate(grenadePrefab, transform.position, Quaternion.identity);

//add force to the prefab
grenadePrefab.rigidbody.AddForce(transform.forward * 2000);

Collisions = Collisions.GRENADE_AMMO --;
print (“You Now Have “+ GRENADE_AMMO +” Grenades”);
}

New Code
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == “CrateGrenades”)

{
//destroy the ammobox
Destroy(hit.gameObject);

Collisions = GRENADE_AMMO --;

//add ammo to inventory
Collisions.GRENADE_AMMO += 8;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == “CrateGrenades”)

{
//destroy the ammobox
Destroy(hit.gameObject);

Collisions = GRENADE_AMMO --;

//add ammo to inventory
Collisions.GRENADE_AMMO += 8;"