getting url from variable that calls picture of current page, not working. Only displays everything instead of url

get_the_post_thumbnail function returns the post thumbnail image tag as a string.
Use get_the_post_thumbnail_url function instead to get url.

$url = get_the_post_thumbnail_url($pid, 'full');