Help with distance between two objects

I’m trying to make a script which allows a player to enter a vehicle, so far I have this code which should make a message pop up when the player is near the vehicle game object. However, the message always appears no matter the distance. Any help would be greatly appreciated, thanks.

using UnityEngine;
using System.Collections;
using System;

public class VehicleEntering : MonoBehaviour {
	public float threshold = 1;
	public static Transform playerObject;
	public Transform playerObjectInspector;
	public static Transform vehicleObject;
	public Transform vehicleObjectInspector;
	private void Awake() {
		playerObject = playerObjectInspector;
		vehicleObject = vehicleObjectInspector;
	void Update() {
		float distance = Vector3.Distance (VehicleEntering.playerObject.transform.position, VehicleEntering.vehicleObject.transform.position);
		if (distance <= threshold) {
	void OnGUI() {
			GUI.Box(new Rect(0,0, Screen.width, Screen.height), "Press E to enter vehicle");


OnGUI is a special unity controlled function It is not advised to call it yourself, instead replace your OnGUI call with setting a boolean value to true (and false in an else statement to turn it off when out of range) then just check that flag in the OnGUI function so that it only draws the label if the flag is set.