Is there a way to connect my playerhealth script with my damage script so the player can lose health

Damage Script

using UnityEngine;
using System.Collections;

public class DamageScript : MonoBehaviour {

    void OnTriggerEnter2D(Collider2D col)
    {
        if(col.transform.root != transform.root && col.tag != "Ground" && !col.isTrigger)
        {
            if(!col.transform.GetComponent<Player1Control>().damage)
            {
                col.transform.GetComponent<Player1Control>().damage = true;

                col.transform.root.GetComponentInChildren<Animator>().SetTrigger("Damage");
            }
        }
    }
}

HealthScript

using UnityEngine;
using System.Collections;

public class PlayerHealth : MonoBehaviour
{
    public float max_Health = 100;
    public float cur_Health = 0;
    public GameObject healthBar;
   
   
    void Start ()
    {
        cur_Health = max_Health;
        InvokeRepeating("decreasehealth", 1f, 1f);
    }

    void Update (){

    }

    void decreasehealth()
    {
        cur_Health -=0;
        float calc_Health = cur_Health / max_Health;// if cur 89/ 169 - 0.8f
        SetHealthBar (calc_Health);
    }

    void SetHealthBar(float myHealth)
    {
        //myHealth value 0-1 ,
        healthBar.transform.localScale = new Vector3(myHealth, healthBar.transform.localScale.y, healthBar.transform.localScale.z);
    }

}

Ofcourse there is, when do you want to apply the demage though ? When the player enters the trigger ?

Yes I want it when the player enters the trigger.

In your damage script in the OnTriggerEnter2D() function, you’ll just have to reference your enemies health script as well, just like you reference the enemies Animator (if I’m seeing that correctly). Is the HealthScript attached to your enemy gameobject?

If so, I think all you need to do is simply add this line underneath line 14 in your damage script:
col.transform.root.GetComponent().decreasehealth();

But…your decreasehealth function (as you have it there) is subtracting nothing from your health. So I’m not sure if you have “0” there as a placeholder, or if you need to change that. Also you have your variable “public float cur_Health =0;” as zero, so I’m assuming your setting that via the inspector or from some other code perhaps.

**Edit: If you’re wanting to apply damage and play the damage animation on the gameobject holding both of those scripts, then it’s even easier actually. But I don’t know if you’re trying to apply damage to an enemy gameobject from the enemies collider, or to the friendly gameobject from its own collider.

I’m making a fighting game and want both of them to lose health. Looks like I’m going to have to make a new player health script so that they can be separate. I have the 0 in place because if I add a number to it my player starts losing health on its own.