That's a very broken way to fix that problem :p
Not a good idea to call those commands repeatedly like that, it would use up a lot of resources if used in too many scripts.
What you need to do is make sure the command is only called if the animation is not already playing (assuming you wanted it to repeat for the duration the player is close enough) or simply toggle the condition to no longer be true after it has been triggered (even in such a way that it can no longer trigger again maybe?).
The play animation call will repeatedly try to run the animation every time it is called, therefore it is stuck in the first frame and appears not to be animating, once you move away the last call is still active and thus the animation plays... Making it look like the condition is reversed but its simply the way the call works.
An easy example of this is the play sound call. You will notice a weird buzzing if the command is called repeatedly and when you move away the sound is played normally, this is because of the same trait.
So basically you want to enclose the commands inside an extra check - by default GG scripts use
if g_Entity[e]['animating'] == 0 then
Because this automatically gets reset to 0 by the engine once the entity stops animating.
Just remember to also set it to a value once you have called the play animation command (it doesn't change by default I assume because it allows you to set values and easily grab which animation is playing based on those).
On phone so forgive any error but the script will look something like this.
if GetPlayerDistance(e) < 200 then
if g_Entity[e]['animating'] == 0 then
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
end
end