How do I test when a player moves forward?
Solution 1:
I made a movement detection system a while ago that I think could be useful for this. You can use it as a reference or modify it to fit your creation.
You will need 1 repeating command block and 15 chain command blocks connected to it (all set to always active). Here are the commands: https://pastebin.com/445LRfFz
And here is the system in action:
it stores the player's current position into some scoreboard objectives (x and z). Then, it constantly compares the player's x objective to the player's prev_x objective to see if there are any changes. If x is greater than prev_x, that means the player has moved towards positive x. I also made it so it tags the player with "x+" and then says "x+" in chat.