Changing Variable through Move-Route

Hi everyone, I'm attempting to change a variable through the script command in the custom Move-Route.

I'm trying to change variable 21 to be the X coordinate of the current event that is moving.

Here's what I've tried so far;
$gameVariables.setVariable(21, $gameMap._events[this._eventId].x);
but I keep getting an error: undefined is not a function

Could someone help me figure out what I'm doing wrong?
The function you're trying to invoke is setValue, not setVariable. If you fix that, you should be good to go.
The function you're trying to invoke is setValue, not setVariable. If you fix that, you should be good to go.

Such a simple oversight on my end, thank you for the quick response! Everything is working as intended now.
$gameVariables.setValue(21, this.x)

Original thread: https://forums.rpgmakerweb.com/threads/changing-variable-through-move-route.90332/