Enemy chase player behavior not working

Hey guys.

Just wondering if you see something wrong with this code I have for my enemies in the game.
It works fine down to the point where Player gets too close and the enemy should start move to player. When I get close the enemy just freezes and stays like that.

I don’t understand why you need variable and distance check where distance check would be enough

You could simply check if distance is below 100 and instead of this

Check if distance is above 100 (you use same condition and invert it)
Same with timer
Why you inverted it instead of checking if its above some value?

To my understanding you want so that if enemy is in range of player he chase player
But when enemy is outside of player range he waits 4 sec then go back to spawn point

If so i really see no reason for that attacking player variable to exist

Also it would be wise to move enemy back to spawn only if he is not in range of his spawn point
Not to spam this event over and over

For example use another var to set where enemy should return to (i see you use random in range there)
And check if enemy X position is greater than that variable +3
And less than that var -3
Or 2 or whatever
And do the same for Y
Which would stop spaming that event once destination is reached