# How to Make an Enemy Patrol Back and Forth in Scratch > Turn 180 degrees whenever the enemy crosses left or right patrol limits. Learn how to make an enemy patrol back and forth in Scratch with clean block recipes, testing tips, and related guides. ## Minimal Working Block Recipe Turn 180 degrees whenever the enemy crosses left or right patrol limits. Test this minimal version first, then tune numbers like speed, gravity, or timing to match your game feel. **Make an Enemy Patrol Back and Forth script** - forever - move (4) steps - if <<(x position) > (150)> or <(x position) < (-150)>> then turn (180) degrees Try it: Reliable platform or corridor patrol enemy. ## Debugging Checklist & Next Steps If it behaves unexpectedly, verify initial variable resets on the green flag and check that continuous checks sit inside a forever loop. - [Related Deep-Dive Guide](/en/techniques/enemies/): Explore full mechanics and variations. - [All 120 Scratch How-To Recipes](/en/howto/): Return to the reverse lookup index. Updated: 2026-11-23 Author: [Takamasa Suzuki](https://scratch.gmnavi.jp/about/author/) Japanese Edition: https://scratch.gmnavi.jp/howto/patrol-enemy/ [Scratch Daizen (English)](https://scratch.gmnavi.jp/en/)