How to make my NPC move automatically on the X-axis.

I have a game where I want to add NPC’s that move on the x-axis automatically.
The game is an infinite runner kind of game.
The NPC’s should move from side to side (on a restricted axis) by themselves. (When hitting the given max -position, start moving back to the other direction)
I just don´t really know how to script this…

follow any youtube tutorial