Making Interactions Between Player and NPC, One Script Makes Other Scripts Not Work

As the title stated, I’m making a game where you can interact with an NPC Ally that follows you around named Anthony. I’ve been running into some issues where I have 3 different scripts on the player that call for interactions between Anthony, who is tagged with “NPC” (“OnTriggerEnter” if the collider is tagged with “NPC”)

One script is upon pressing E, you can talk to him and he’ll give you a random line of dialogue,

Another is if you left click on him when you’re in his collider trigger, you can “hit” him and he essentially animates and lets out a yelp or another line of hurt dialogue. Both of these scripts work together okay, but when I added on the third script, which is when the player picks Anthony up by pressing P, and puts him down by pressing O (when you press P, the NPC is set to inactive, and a model of him riding your shoulders is set to active, and then when pressing O, vise versa happens. This is coded this way because the character also doubles as a grappling hook.) This script is seemingly prioritized and the other scripts stop working.

I’ve looked everywhere for an answer, I’ve received one that wasn’t even for unity 3D, and I’m just stumped at this point.

Here are the three scripts:

Hurt Script

///Hurt Script (when you left click when you're close enough to Anthony to hit him)

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

public class anthonyHurt : MonoBehaviour
{

    public GameObject player;
    public AudioSource source;

    public GameObject pickUpText;
public Animator anim;
   
    public AudioClip[] clips;

    public bool inReach;


   protected void Start()
    {

        pickUpText.SetActive(false);

      anim = GetComponent<Animator>();

        inReach = false;
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "NPC")
        {
            inReach = true;
            pickUpText.SetActive(true);
        }
    }

void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "NPC")
        {
            inReach = false;
            pickUpText.SetActive(false);
        }
    }
// Update is called once per frame
    void Update()
    {
        if(Input.GetMouseButtonDown(0) &&inReach)
        {
       anim.Play("Hurt",0,0);
          int randomClip = Random.Range (0, clips.Length);
        source.clip = clips[randomClip];
        source.Play ();
        }
    }

}

Dialogue Script

///Dialogue Script (when you press E to talk to Anthony)

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

public class forplayer : MonoBehaviour
{
  
  public AudioSource source;
    public AudioClip[] clips;

   private bool triggering;
   public GameObject npcText;
   private GameObject triggeringNpc;

  
   void Start()
   {
    AudioSource source = gameObject.GetComponent<AudioSource> ();
   }

   void Update()
   {
    if(triggering)
    {
       npcText.SetActive(true);

       if (Input.GetKeyDown(KeyCode.E) && !source.isPlaying)
       {
        int randomClip = Random.Range (0, clips.Length);
        source.clip = clips[randomClip];
        source.Play ();
       }
      
    }
    else {
        npcText.SetActive(false);
    }
   }

   void OnTriggerEnter(Collider other)
   {
    if (other.tag == "NPC" )
    {
        triggering = true;
        triggeringNpc = other.gameObject;
    }
   }

   void OnTriggerExit(Collider other)
   {
        if (other.tag == "NPC" )
    {
        triggering = false;
        triggeringNpc = null;
    }
   }
  
  
}

And finally, the Pickup Script.

///Pick Up Anthony (pick Anthony up by pressing P and put him down by pressing O)

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

public class PickupAlly : MonoBehaviour
{
    public GameObject shoulderRider;

    public Animator anim;

    private bool triggering;

    public GameObject ally;

   void Start()
    {


        anim = transform.parent.GetComponent<Animator>();

    }



void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "NPC")
        {
           
            anim.SetBool("PickupTrigger", true);       

                     
        }
    }



void OnTriggerExit(Collider other)
{
        if (other.gameObject.tag == "NPC")
     {

        anim.SetBool("PickupTrigger", false);
   
     }
}



void Update()

{
    if (anim.GetCurrentAnimatorStateInfo(0).IsName("Reaching"))
   
   
   { if (Input.GetKeyDown(KeyCode.P))
            {
      
               shoulderRider.SetActive(true);
                ally.SetActive(false);


            }
}

if (ally.activeSelf == false)
   
   
   { if (Input.GetKeyDown(KeyCode.O))
            {
      
               shoulderRider.SetActive(false);
                ally.SetActive(true);

            }
}

}
}

Any help is greatly appreciated!

I guess the question is, in what way to do they stop working? Do they just not work any more? Do they break in some way?

As far as I’m aware, they just completely stop working, but they work in other scenes. I’m gonna check everything again to make sure I’m not missing something.

From looking at the code, I can only see that they would stop working is when Anthony gets disabled, but that should start working again when he’s re-enabled.

As always this is a case of debugging. You’ll want to check what code is or isn’t executing with Debug.Log, or attaching the debugger from your IDE (if supported) to step through the execution of your code. Once you understand what isn’t running, you can start to investigate why.

Wow I’m a huge dummy, I just checked the player object and I forgot to set the public objects and stuff like that lol

Thank you for the help