How do I change variables at collision with Player? Please Help.

How do I change variables, when the player collides with an object. I want to make if the player collides with an item, then the variable FireRate of the cannon changes.
Can you help me, please?

//C#
public void OnCollisionEnter(Collision col){
if(col.gameObject.CompareTag(“Item”))
firerate = 10;
}

//Javascript
function OnTriggerEnter (col : Collider) {
    if(col.gameObject.CompareTag("Item"))
    firerate = 10;
}

Have a great day!