Im trying to get a value off another script. I'm not getting any error, but I'm getting 0 instead of 5. What am I doing wrong?

this is the script on the hazard:

public class hazard : MonoBehaviour
{

    public double hurt(){
        double dam = 5.0;
        return dam;
    }
}

this is the script on the player trying to get damage off the hazard object:

public class collect : MonoBehaviour
{
    public double Health;
    private double hazz;
    void Start()
    {
        Health = 5;
    }


     private void OnTriggerEnter(Collider other) {
        if(other.gameObject.CompareTag("Bad")){
            hazz=other.gameObject.GetComponent<hazard>().hurt();
        }
    }
}

The default value for a double is 0. My guess is that your collider script is not working - check that you have box colliders and rigid bodies attached to the game objects you are trying to collide.

Also, add some debug.log statements to your code to verify that it runs, e.g.

      private void OnTriggerEnter(Collider other) {
         Debug.Log("OnTriggerEnter firing");
         if(other.gameObject.CompareTag("Bad")){
         Debug.Log("OnTriggerEnter-Bad Tag found");
             hazz=other.gameObject.GetComponent<hazard>().hurt();
         }

You can remove the debug.log statements once you have verified that its all working.

Thank you! This helped. The problem as actually really simple: I used a Plane for the trigger as opposed to a box.