Global_player.global_position and global_position are exactly the same thing in this case, you’re basically doing this:
self.global_position.x - self.global_position.x
so the result of this calculation will always be 0, so your sprite will never flip.
If this script is on your enemy, then you should reference the player in the Global_player variable.
What do you mean nothing worked? What did you try to do?
Please share your code/screenshots/everything that might be useful, otherwise it’s hard to help you.
do not copy my script, you have to understand the code. as i said target is the player so send your player scene information in the code. and anim is the animated sprite. @onready var anim=$AnimatedSprite2D