Distance to object clicked

How to I check to see if my player is in range, when they click on an object? For example, if a player clicks on a portal I want it to check if he’s in range, before opening a widget option.