Why does my enemy teleport to my player?

I’m running into a glitch where my enemy is teleporting to my player. Can anyone help me to rewrite the code so this doesn’t happen?

Link to video showing enemy glitch teleport.

Because you need to yield in the Attack() function when the distance > 5f. Otherwise, you’re just running that while loop all in one frame.

You’ve set the video in the link to private, so I can’t really help, sorry :frowning: