Why am i getting an error?

So i have a GameObject called playbutton when it is clicked it goes to my loadingscreen there my loadingscreen determines a bunch of stuff to know what to load which is fine except for one small line.

if(playbutton.GetComponent<PlayB>().startgame == true)

so this is a gameobject and its public and its assigned in the inspector but i get

UnassignedReferenceException: The variable playbutton of LoadingScreen has not been assigned.
you probably need to assign the playbutton variable of the Loading Screen script in the inspector.

and guess what it is assigned in the inspector i see nothing wrong here, maybe somebody would like to correct me?

also startgame is a bool in the PlayB script which is set to true when the button is clicked and loads the loading screen.

u can add one more if condition :

if(playbutton != null)
    //add your code here

Thanks… This may solve your problem