Need Help Accessing scripts from other scenes.

I need to be able to access the isInteraction 1,2,3 and 4 from the dialog manager and the hasBeenToScene 1,2,3 and 4 from my playerController but they are being used in differant scenes. How can i do that

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

public class PlayerController : MonoBehaviour {

    public float moveSpeed;
    public float jumpForce;
    public float speedMultiplier;
    private float moveSpeedStore;

    public float speedIncreaseMilstone;
    private float speedIncreaseMilestoneStore;
    private float speedMilestoneCount;
    private float  speedMilestoneCountStore;

    public GameManager theGameManager;

    public float jumpTime;
    private float jumpTimeCounter;

    public bool hasBeenToScene1;
    public  bool hasBeenToScene2;
    public  bool hasBeenToScene3;
    public  bool hasBeenToScene4;
    private bool stoppedJumping;
    public bool canDoubleJump;

    public ScoreManager scoreManager;
    public DialogueManager dialogueManager;

    public Transform Text2;
    public Transform Text3;
    public Transform Text4;
    public Transform Text5;

    private Rigidbody2D myRightBody;

    public bool grounded;
    public LayerMask whatIsGround;
    public Transform groundCheck;
   
    public float groundCheckRadius;
  
   
    //private Collider2D myCollider;
   
    private Animator myAnimator;

    // Use this for initialization
    void Start ()
    {
        myRightBody = GetComponent<Rigidbody2D>();

        stoppedJumping = true;
       

        myAnimator = GetComponent<Animator>();

        jumpTimeCounter = jumpForce;
        speedMilestoneCountStore = speedMilestoneCount;
        speedIncreaseMilestoneStore = speedIncreaseMilstone;

        Text5.GetComponent<BoxCollider2D>().enabled = true;
        Text4.GetComponent<BoxCollider2D>().enabled = true;
        Text3.GetComponent<BoxCollider2D>().enabled = true;
        Text2.GetComponent<BoxCollider2D>().enabled = true;
    }
   
    // Update is called once per frame
    void Update ()
    {

      







        //grounded = Physics2D.IsTouchingLayers(myCollider, whatIsGround);

        grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius,whatIsGround);


        if (transform.position.x > speedMilestoneCount)
        {
            speedMilestoneCount += speedIncreaseMilstone;
            speedIncreaseMilstone = speedIncreaseMilstone * speedMultiplier;

            moveSpeed = moveSpeed * speedMultiplier;
        }


   
    myRightBody.velocity = new Vector2(moveSpeed, myRightBody.velocity.y);
   
    if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))   
    {
        if(grounded)
        {
               
                myRightBody.velocity = new Vector2(myRightBody.velocity.x, jumpForce);
                stoppedJumping = false;
            }

            if (!grounded && canDoubleJump)
            {
                Debug.Log("Double Jumping");
                myRightBody.velocity = new Vector2(myRightBody.velocity.x, jumpForce);
                jumpTimeCounter = jumpTime;
                stoppedJumping = false;
                canDoubleJump = false;
            }
        }
    
     if((Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0)) && !stoppedJumping)   
     {
         if(jumpTimeCounter > 0)
        {

             myRightBody.velocity = new Vector2(myRightBody.velocity.x, jumpForce);
            jumpTimeCounter -= Time.deltaTime;
        }
       
     }
    
     if(Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0))   
     {
         jumpTimeCounter = 0;
        stoppedJumping = true;
     }
    
     if(grounded)
     {
         jumpTimeCounter = jumpTime;
        canDoubleJump = true;
     }
     
      myAnimator.SetFloat("Speed", myRightBody.velocity.x);
      myAnimator.SetBool ("Grounded", grounded);

        if (scoreManager.scoreCount >= 50 && hasBeenToScene1 == false)
        {
            Debug.Log("SceneLoaded1");
            SceneManager.LoadScene("Text2");
            dialogueManager.isInteraction1 = true;
        }
        if (scoreManager.scoreCount >= 750 && hasBeenToScene2 == false)
        {
            dialogueManager.isInteraction2 = true;
            Debug.Log("SceneLoaded2");
            SceneManager.LoadScene("Text2");
        }
        if (scoreManager.scoreCount >= 1000 && hasBeenToScene3 == false)
        {
            dialogueManager.isInteraction3 = true;
            Debug.Log("SceneLoaded3");
            SceneManager.LoadScene("Text2");
        }
        if (scoreManager.scoreCount >= 1500 && hasBeenToScene4 == false)
        {
            dialogueManager.isInteraction4 = true;
            Debug.Log("SceneLoaded3");
            SceneManager.LoadScene("Text2");
        }
    }




        void OnTriggerEnter2D(Collider2D other)
{

            if (other.gameObject.tag == "killbox")
             {
                Debug.Log("Worked");
                theGameManager.RestartGame();
                moveSpeed = moveSpeedStore;
                speedMilestoneCount = speedMilestoneCountStore;
                moveSpeed = 5f;
             }
         }  
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class DialogueManager : MonoBehaviour {

    public Text nameText;
    public Text dialogueText;

    public Animator animator;

    public PlayerController player;

    public bool isInteraction1;
    public bool isInteraction2;
    public bool isInteraction3;
    public bool isInteraction4;

    public Transform Text2;

    private Queue<string> sentences;
    private PlayerController playerController;

    // Use this for initialization
    void Start () {
        sentences = new Queue<string>();
    }

    public void StartDialogue (Dialogue dialogue)
    {
        animator.SetBool("IsOpen", true);

        nameText.text = dialogue.name;

        sentences.Clear();

        foreach (string sentence in dialogue.sentences)
        {
            sentences.Enqueue(sentence);
        }

        DisplayNextSentence();
    }

    public void DisplayNextSentence ()
    {
        if (sentences.Count == 0)
        {
            EndDialogue();
            return;
        }

        string sentence = sentences.Dequeue();
        StopAllCoroutines();
        StartCoroutine(TypeSentence(sentence));
    }

    IEnumerator TypeSentence (string sentence)
    {
        dialogueText.text = "";
        foreach (char letter in sentence.ToCharArray())
        {
            dialogueText.text += letter;
            yield return null;
        }
    }

    void EndDialogue()
    {
        animator.SetBool("IsOpen", false);


       new WaitForSeconds(3);
        {
            if (isInteraction1)
            {
                SceneManager.LoadScene("LightSide");
                playerController.hasBeenToScene1 = true;
            }
            if (isInteraction2)
            {
                SceneManager.LoadScene("LightSide");
                playerController.hasBeenToScene2 = true;
            }
            if (isInteraction3)
            {
                SceneManager.LoadScene("LightSide");
                playerController.hasBeenToScene3 = true;
            }
            if (isInteraction4)
            {
                SceneManager.LoadScene("LightSide");
                playerController.hasBeenToScene4 = true;

            }


        }
       
    
    }

}

You probably want to make them a singleton. Then they can be accessed in any scene, but they won’t create duplicates.

The player, though, I would move that information to a game manager, and maybe the dialogue information also, or you can have multiple managers on one empty game object that are singletons.

This can be easily achieved using static classes:

Public static class DialogueManager
{
public static bool isInteraction1 = false;
public static bool isInteraction2 = false;
public static bool isInteraction3 = false;
public static bool isInteraction4 = false;
}

Make sure you save this in the Assets Folder. This script cannot be put on any gameobject but you can access the variables from any scene and even change their values.

Cheers!

This is the simplest solution if you’re unfamiliar with the singleton approach.
Formatted for your viewing…

Public static class DialogueManager {
    public static bool isInteraction1 = false;
    public static bool isInteraction2 = false;
    public static bool isInteraction3 = false;
    public static bool isInteraction4 = false;
}

It would be an idea to add a handful of helper methods to do things such as resetting all the interactions etc.