I want that when the player have low health, a red screen (already did a loop animation for it) with an animation plays (it plays automatically that's why im just activating the gameObject),I tried to do it with saving the value in a text file and read it from the other script, but is not optimized and it doesn't work, what it looks like :
    public void CreateText()
    {
        string path = Application.dataPath + "/Datas/data";
        if (!File.Exists(path))
        {
            File.WriteAllText(path, "" + health);
        }
        else
        {
            File.Delete(path);
            File.WriteAllText(path, "" + health);
        }
    }
In the other Script :
    public int health = 1000;
    public string health0;
    public string path = Application.dataPath + "/Datas/data";
    public GameObject healthbar;
    void Update()
    {
        Int32.TryParse(health0, out health);
        File.ReadLines(path);
        if (health <= 600)
        {
            healthbar.SetActive(true);
        }
        else
        {
            if (healthbar.activeInHierarchy == true)
            {
                healthbar.SetActive(false);
            }
        }
    }
 
     
    