how can I have a game object get a variable from a different object with collision

so i have a basic player and when the hit a pick up (health or damage) I want then to get the value or val variable off the object to pass into this function on there script

void OnCollisionEnter(Collision other) {
		//if (other.gameObject.CompareTag ("Damage")) {

		if (other.gameObject.name=="Damage"){
			//GameObject timp= other.collider.gameObject.GetComponent (HP_Val);
			HP_fill.fillAmount = HP.SetHP (**"How do I get Val here?"**);
			HPtext.text = HP.desplay_HP;
			//Destroy (other.gameObject);
			if (HP.Helth == 0) 
			{
				m_Animator.SetBool("KO", true);
			}
		}
	}

I know this is do able but what am I missing?

lets assume that your damage/health pack classes are called “DamagePack” and “HealthPack” and each has a public variable called “value”. Here is how you could test for and get those variables.

        // Try to find components on the object.
        HealthPack lHealthPack = other.gameObject.GetComponent<HealthPack>();
        DamagePack = lDamagePack = other.gameObject.GetComponent<DamagePack>();


        if (lHealthPack != null)
        {
            // you have a health pack just use lHealthPack.value to increase health.
        }
        if (lDamagePack != null)
        {
            // you have a damage pack just use lDamagePack.value to decrease health.
        }