Variables arent working when the object is instantiated!

My mountable turret is working great but its supposed to be buildable so when i instatiate my turret on my buildable area my text variable and my player variable arent working any variables assigned dont stay assigned unless there are a child how would i make it so the variables stay even if they arent a child of the object

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Mountable : MonoBehaviour {

    public GameObject inTriggerText;
    public GameObject Player;
    public GameObject Turret;
    public GameObject turretCam;
    public bool inTrigger;



    void Start() {
        inTriggerText.SetActive(false);


    }

    void Update () {

        if (inTrigger && Input.GetKey(KeyCode.E)) {

            Debug.Log("pressed e in trigger");
            Player.SetActive(false);
            turretCam.SetActive(true);
            ((MonoBehaviour)Turret.GetComponent("Shooting")).enabled = true;
            ((MonoBehaviour)Turret.GetComponent("SimpleMouseRotator")).enabled = true;
            inTriggerText.SetActive(false);


          }

        if (Input.GetKey(KeyCode.Space)) {

            Player.SetActive(true);
            turretCam.SetActive(false);
            ((MonoBehaviour)Turret.GetComponent("Shooting")).enabled = false;
            ((MonoBehaviour)Turret.GetComponent("SimpleMouseRotator")).enabled = false;
            inTriggerText.SetActive(false);

        }

    }

    
    


    void OnTriggerEnter(Collider other)
    {


       


        if (other.tag == "Player")
        {
            Debug.Log("Testing if player enters zone");
            inTriggerText.SetActive(true);
            inTrigger = true;
        }
        
    }


    void OnTriggerExit(Collider other) {

        if (other.tag == "Player") {
            inTriggerText.SetActive(false);


        }


    }




}

Prefabs can’t have references to objects in the scene unless the reference is in the same prefab. What (I think) you’re asking is impossible, you can’t reference objects on the scene from a prefab, you can’t fix that, it’s how they work by design.

You’ll have to get those instances at runtime with things like GameObject.Find, GameObject.FindObjectOfType or anything else that lets you search the hierarchy for a particular GameObject. Something like:

void Awake() {
    Player = GameObject.Find("Player");
}