Delete animation

Hi guys I have a question: how can I delete an animation (bang) trigger by press key if one of my Player object (Crossbow) is deactivate?:
Is it correct my script? Thank a lot

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class deletebow : MonoBehaviour
{

  public Animator anim;
    public GameObject Crossbow;

    // Use this for initialization
    void Start()
    {
        anim = GetComponent<Animator>();
    }

    // Update is called once per frame
    void update()
    {
        if (Crossbow.activeSelf)
        {
            anim.SetBool("bang", false);

        }
    }
}

You can’t have a deactivated object act of its own accord. You’ll have to create another script that’s active, and have that trigger whatever functions you need to on the deactivated object.

Also, your “update” needs to be “Update”. Uppercase matters here

No no …I have created a script that when press a button ui a object child of a Player became active or disactive and when prese a key plays an animation reported to a object. I would want that if the object is not active and press key, the reported animation became disabled…just when the object is active played animation.