npc only moves in one direction

Godot Version

4.4.1

Question

I have this script for idle and movement on an npc. I want it so that the npc chooses to stand idle or move in a random direction for a second or two. When I run the scene I notice the NPC stops randomly, but will only move to the right. They wont move up, down, or left. Only go idle or move to the right.

I was following this guide on youtube. He begins his script at 3:15

my script


I notice that when I change the dir = Vector2.RIGHT to Vector2.LEFT or anything else it will choose to go only in that direction as well.

I am new to programming and game dev any help would be appreciated

Are you sure you’re changing state? Also, print_debug(dir) after changing it