Acceed variables from other scripts

Hello, I want to read the value of a bool variable that was created in another script:

Script 1: Player controller

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

public class PlayerController : MonoBehaviour
{
    // Variables
    public GameObject uno, dos, tres, cuatro, cinco, seis, siete, ocho, nueve, diez, once, doce, trece, catorce, quince, dieciseis, diecisiete, dieciocho, diecinueve, veinte, veintiuno, veintidos, veintitres, veinticuatro, veinticinco, veintiseis, veintisiete, veintiocho, veintinueve, treinta, treintayuno, treintaydos, treintaytres;
    [Range(0, 30)] public float speed = 25f;
    public float turnSpeed = 40f;
    private float horizontalInput;
    private float verticalInput;
    public int lifes = 3;
    public bool finished = false;

    // Start is called before the first frame update
    void Start()
    {
       
    }

    void OnCollisionEnter(Collision collision)
    {
        if(collision.gameObject.name == "Meta")
        {
            finished = true;
            Destroy(this.gameObject);
        }

        if(collision.gameObject.name == "1" || collision.gameObject.name == "2" || collision.gameObject.name == "3" || collision.gameObject.name == "4" || collision.gameObject.name == "5" || collision.gameObject.name == "6" || collision.gameObject.name == "7" || collision.gameObject.name == "8" || collision.gameObject.name == "9" || collision.gameObject.name == "10" || collision.gameObject.name == "11" || collision.gameObject.name == "12" || collision.gameObject.name == "13" || collision.gameObject.name == "14" || collision.gameObject.name == "15" || collision.gameObject.name == "16" || collision.gameObject.name == "17" || collision.gameObject.name == "18" || collision.gameObject.name == "19" || collision.gameObject.name == "20" || collision.gameObject.name == "21" || collision.gameObject.name == "22" || collision.gameObject.name == "23" || collision.gameObject.name == "24" || collision.gameObject.name == "25" || collision.gameObject.name == "26" || collision.gameObject.name == "27" || collision.gameObject.name == "28" || collision.gameObject.name == "29" || collision.gameObject.name == "30" || collision.gameObject.name == "31" || collision.gameObject.name == "32" || collision.gameObject.name == "33")
        {
            lifes = lifes - 1;
            switch (collision.gameObject.name)
            {
                case "1":
                    Destroy(uno);
                    break;
                case "2":
                    Destroy(dos);
                    break;
                case "3":
                    Destroy(tres);
                    break;
                case "4":
                    Destroy(cuatro);
                    break;
                case "5":
                    Destroy(cinco);
                    break;
                case "6":
                    Destroy(seis);
                    break;
                case "7":
                    Destroy(siete);
                    break;
                case "8":
                    Destroy(ocho);
                    break;
                case "9":
                    Destroy(nueve);
                    break;
                case "10":
                    Destroy(diez);
                    break;
                case "11":
                    Destroy(once);
                    break;
                case "12":
                    Destroy(doce);
                    break;
                case "13":
                    Destroy(trece);
                    break;
                case "14":
                    Destroy(catorce);
                    break;
                case "15":
                    Destroy(quince);
                    break;
                case "16":
                    Destroy(dieciseis);
                    break;
                case "17":
                    Destroy(diecisiete);
                    break;
                case "18":
                    Destroy(dieciocho);
                    break;
                case "19":
                    Destroy(diecinueve);
                    break;
                case "20":
                    Destroy(veinte);
                    break;
                case "21":
                    Destroy(veintiuno);
                    break;
                case "22":
                    Destroy(veintidos);
                    break;
                case "23":
                    Destroy(veintitres);
                    break;
                case "24":
                    Destroy(veinticuatro);
                    break;
                case "25":
                    Destroy(veinticinco);
                    break;
                case "26":
                    Destroy(veintiseis);
                    break;
                case "27":
                    Destroy(veintisiete);
                    break;
                case "28":
                    Destroy(veintiocho);
                    break;
                case "29":
                    Destroy(veintinueve);
                    break;
                case "30":
                    Destroy(treinta);
                    break;
                case "31":
                    Destroy(treintayuno);
                    break;
                case "32":
                    Destroy(treintaydos);
                    break;
                case "33":
                    Destroy(treintaytres);
                    break;
            }
        }
    }

    // Update is called once per frame
    void Update()
    {
        horizontalInput = Input.GetAxis("Horizontal");
        verticalInput = Input.GetAxis("Vertical");
        if(lifes > 0)
        {
            if(finished == false)
            {
                this.transform.Translate(speed*Time.deltaTime*Vector3.forward*verticalInput);
                this.transform.Rotate(turnSpeed*Time.deltaTime*Vector3.up*horizontalInput);
            }
        }
    }
}

Script 2: FollowPlayer

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

public class FollowPlayer : MonoBehaviour
{
    // Variables
    public GameObject player;
    public Vector3 offset = new Vector3(0, 15, -10);
   
    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        if(finished == false)
        {
            this.transform.position = player.transform.position + offset;
        }
    }
}

In line 20 i get this error:
Assets\Scripts\FollowPlayer.cs(20,12): error CS0103: The name ‘finished’ does not exist in the current context

¿How can I use the variable finished in FollowPlayer?

You get a reference to the other script. Either through GetComponent or just placing the value in the Inspector.

Referencing variables, fields, methods (anything non-static) in other script instances:

REMEMBER: it isn’t always the best idea for everything to access everything else all over the place. For instance, it is BAD for the player to reach into an enemy and reduce his health.

Instead there should be a function you call on the enemy to reduce his health. All the same rules apply for the above steps: the function must be public AND you need a reference to the class instance.

That way the enemy (and only the enemy) has code to reduce his health and simultaneously do anything else, such as kill him or make him reel from the impact, and all that code is centralized in one place.

As I said before, you SERIOUSLY want to learn how to use collections and arrays! The folliwng code will be a nightmare to maintain!!

8405109--1110045--Screen Shot 2022-08-31 at 6.43.21 AM.png