I don't think that's what he wants (and besides, I need to fix that script).
I think he means he wants the guard to always prevent the player from going past that line. He doesn't want the guard to follow him; he just wants the guard to always be on the same X-coordinate as the player.
@michael95 - One way to event this would be to run a parallel process event in the map which looks something like this:
Loop
Control Variables [X Difference] = Player's Map X
Control Variables [X Difference] -= [Guard]'s Map X
Conditional Branch: Variable [X Difference] > 0
Move Event: Guard -> Move Right
Wait: 6 frames
Else
Conditional Branch: Variable [X Difference] < 0
Move Event: Guard -> Move Left
Wait: 6 frames
Else
Break Loop
Branch End
Branch End
Move Event: Guard -> Turn Down
Wait: 6 frames
That would be the basic idea anyway - I don't know how many each of the wait frames would have to be.
And of course, the guard will have to be at least as fast as the player for this to work.
EDIT::
I've attached a picture of the event as that will probably be of more assistance: