Error:NullReferenceException: Object reference not set to an instance of an object

this error keeps showing up and crashing the game , it relates to a DoorOpen script which also connects to its respective Switch script however this segment of the script(shown below) which is trying to locate the player however it keeps stating its targeted to no object

var player = GameObject.FindWithTag(“Player”);
var dist = Vector3.Distance(“Player”.transform.position, transform.position);

use player instead of “Player” in the distance calculation (how did that even compile?)

var player = GameObject.FindWithTag("Player"); 
var dist = Vector3.Distance(player.transform.position, transform.position);

And if that was just a typo, make sure that your player object is actually propperly tagged (and not accidentally just named or using a layer mask with that name instead)

yeh sorry mate its still not working ive checked the typo errors and corrected any mistakes but the same error keeps coming up ,but thanks for your help so far.