Im not saying you cant use it. You just cant be using it before the = sign. Thats a method from the sapphire stone its not a variable to be holding a number.
I just want to point out this does not work for 2 reasons. hero.targetPos = mid(enemy,friend)
hero.targetPos can not be assigned to hold a value. mid(enemy,friend) This method is fine except that it doesnt return anything. It looks like you want use this return value as an object. You need to return an object holding the two new variables.
This can work if you replace the period with _ or nothing have the words touching. Then have your Mid function return an object.
Im just guessing but chances are your error is because your variables dont hold a value when passed. You should check to see if theirs an enemy and a friend before using your function.