Apologies, should've worded my previous advice differently.
But just to identify an issue: Not everything has to be ran through a if-then conditional.
For example, the for-loop which would remain outside of the if-then conditionals,
but still inside the function where you define movement.
Exception: The only time you would put this for-loop in an if-then case is when
checking for obstructions or other things before moving.
Would suggest to read more on what you can do with variables,
but it seems there's an absence of related information in tutorials.
I may make one in the near future seeing as it could be useful.
. . .
for (var i = 0; i < 32; ++i) { QueuePersonCommand(Player, Command, false); }
In my way of doing things, we would leave the "Command" spot as a variable.
We could create this variable locally, within the parameters of the function
where we define movement, presumably before everything else (on top).
First we define it outside of the if-then conditionals, then redefine it inside
them when we're wanting movement during key pressing.
Really, outside the if-thens you could define the local variable "Command" as just about anything,
doesn't matter because that's what we're redefining inside the conditionals.
But for conveniences sake, we should define it as this for now:
var Command = null;
. . .
if (IsKeyPressed(KEY_UP)) {
QueuePersonCommand(Player, COMMAND_FACE_NORTH, true);
moving = true;}
Now for the if-then conditional, we relocate the for-loop outside of its parameters.
We can keep the QueuePersonCommand for facing if we want, but what we
want to add is the redefining of the local variable "Command"
if (IsKeyPressed(KEY_UP)) {
QueuePersonCommand(Player, COMMAND_FACE_NORTH, true);
moving = true; Command = COMMAND_MOVE_SOUTH}
Being that we're pressing KEY_UP we want our player to go North.
So we define Command = COMMAND_MOVE_NORTH;
This causes Command inside the for-loop to be redefine as COMMAND_MOVE_NORTH
whenever KEY_UP is pressed.
Try it this time, and get back to me with your results.
If it doesn't work, attach your script with the movement function and I'll look through.