Ace, if you'd copied the code I posted then you wouldn't have had any of these issues!!
See the original function below as I posted it, note the 'Source' instead of 'cam' as a function parameter. When you call the function use 'cam'.
See the original function below as I posted it, note the 'Source' instead of 'cam' as a function parameter. When you call the function use 'cam'.
Function GetNearestTarget.Target( Source ) Local Found.target MinDistance# = 100000 For t.target = Each target Distance# = EntityDistance( Source , t\Shape ) If Distance < MinDistance MinDistance = Distance Found = t EndIf Next Return found End Function