Enemy npc walk around when out of range

Hello,

I have an issue with my game. I can’t figure out how to let my enemy walk around.
My enemy does follow the player when it is in a range. But I need my enemy to walk around when its outside the range.

This video is a good resource that explains simple back and forth enemy movement, check it out.