Distance between projectile and player ?

I’ve had a lot of problems with getting distance between a shot projectile stuck in a surface and the player that shot it . I then want to check if that distance is bigger than the maximal range. If it isn’t I want to just set the players transform position to that new position of the stuck projectile . I’m also wondering how to set the position in a way so that the player doesn’t enter the surface if the projectile is stuck in the ceiling or any other surface as the center of the player will be moved to the new location .
Here is my simple script :

using UnityEngine;
using System.Collections;
using System.Security.Cryptography;
using System.Collections.Specialized;

public class TeleportSystem : MonoBehaviour
{
	public GameObject dart;
	Vector3 newplayerpos;//the teleportation dart
	public GameObject player;
	Vector3 distance = new Vector3(0, 0, 0);
	float distancevalue;
	public float DartDistance
	{
		get
		{
			distance = Vector3.Distance(dart.transform.position, player.transform.position);
			return distancevalue = distance.magnitude;
		}
	}
	public float maxrange; // the maximal range of the teleport
	public float animationlengthdart; //the animationlength of the dart  
									  // FixedUpdate is called 50 times per second
	void FixedUpdate()
	{
		if (DartDistance < maxrange)
		{

			GetPosition();
			Moveplayer();
			destroydart();
		}
	}
	Vector3 GetPosition() //copies the player position to dart position
	{

		newplayerpos = new Vector3(dart.transform.position.x, dart.transform.position.y, dart.transform.position.z);
		newplayerpos = dart.transform.position;
		return newplayerpos;

	}
	void Moveplayer()
	{
		player.transform.position = newplayerpos;
	}
	void destroydart()
	{
		if (player.transform.position == dart.transform.position)
		{
			Destroy(dart, animationlengthdart);
		}
	}

}

I have resolved the issue with the distance. Turns out it was a super stupid mistake as I thought Vector3.Distance returns a vector3. The other part of the question is still a problem though .