Issues trying to make player turn toward event

Hi all,

I am having some trouble using a Move Route script call to make the player turn toward an event.

When using an eventID, such as:
$gamePlayer.turnTowardCharacter($gameMap.event(2))

everything works just fine; however, for my purposes I need the player to turn towards whatever event is currently active and calling the move route (on the player).

I tried as follows:

$gamePlayer.turnTowardCharacter($gameMap.event(this._eventId))
as well as:
$gamePlayer.turnTowardCharacter($gameMap.event(this.eventId()))

Either case causes the following error:
" Cannot read property 'x' of undefined'

Really getting boggled with this. Will be much grateful for help.
Thank ya'll in advance!
where and when are you calling the function?

"this" is basically a programming shortcut, but it is not always an event. That depends on the context, and your post completely ignores the context.

please give a full screenshot of whatever event uses the command.
When using an eventID, such as:
$gamePlayer.turnTowardCharacter($gameMap.event(2))

everything works just fine; however, for my purposes I need the player to turn towards whatever event is currently active and calling the move route (on the player).

I tried as follows:

$gamePlayer.turnTowardCharacter($gameMap.event(this._eventId))
as well as:
$gamePlayer.turnTowardCharacter($gameMap.event(this.eventId()))
If you're running from the event, why would you try to go back through the current game map just to get the event again? Just $gamePlayer.turnTowardCharacter(this);

Either case causes the following error:
" Cannot read property 'x' of undefined'
You need to post screenshots of the full error trace (press F8, go to the Console tab) because that error is not in the line of code you just typed. It's saying something (probably the event you're trying to turn toward) doesn't exist.

Original thread: https://forums.rpgmakerweb.com/threads/issues-trying-to-make-player-turn-toward-event.150704/