The above code gives an error.

It says 'x' is not a member of 'function'

Should I define player_distance to be a vector?