Incrementing score between two scripts

Hello! I have a game manager script and animal behavior script. I have my game winning conditions and effects set up on the game manager script to run once my score equals 3. The way to score is by pressing a button within a collision detection which sends the animal into the pen and I’d like to increment my score in the animal behavior script, but then access that score on the game manager script to tell the game if the player has won or not.

I’ve tried to reference the score from one script to the other, but it’s not even letting me type it out. Sorry if more information is needed, but let me know if any specifics and I’ll post more.

public void WinGame()
{
    //This is the Winning Script, but need to set it to an actual win condition instead of pressing Q
    if (score == 3)
    {
        if (!hasWon)
        {
            hasWon = true;
            blueFireworks.Play();
            greenFireworks.Play();
            yellowFireworks.Play();
            Cursor.lockState = CursorLockMode.None;
            winScreen.gameObject.SetActive(true);
        }

        if (hasWon)
        {
            return;
        }
    }
}

private void OnCollisionEnter(Collision other)
{
    if (other.gameObject.CompareTag("Barrier"))
    {
        transform.Rotate(Vector3.up, 180);
    }

    if (other.gameObject.CompareTag("Player"))
    {
        if (Input.GetKey(KeyCode.E))
        {
            caughtSound.Play();
            GetCaught();
            //Need to increment score here, store it, and access it on the game manager script to run the WinGame method
        }
    }
}

Again, WinGame() is in the GameManager script and OnCollisionEnter() is in the AnimalBehaviorScript. TLDR: How can I access a score that is incremented and saved in the AnimalBehaviorScript to determine if the game has been won and run my WinGame() on the GameManager script.

Thank you in advance and sorry if any confusion!

Luckily you can keep the score in the GameManager script and have the Animal script update that instead. To start in order to reference the script you will need to set it in the script like:

public GameManager gm; //The Same Location As Your Other Bools, Floats, etc.

void Start()                                            
{ gm = GameObject.Find("GameManager").GetComponent<GameManager>(); } 

After that you should be able to access your score from the Animal Script. If your score is an int, in the same area as where you play the sound effect you could do something like:

gm.score++;

This will add 1 point to your score every time it is run. If it is a float you could do:

gm.score = gm.score + 1f;

I find it is much easier to stay organized allowing the Game Manager to handle things like keeping track of score. Just make sure the score in the game manager is public instead of private, otherwise unity wont be able to find it.