ACTION clip_models {

my.shadow = off;//casts a shadow
my.gravity = off;//gravity off or your tree might float away
wait(1);


while(1)
{


if(my.clipped != on && vec_dist(my.x,player.x) <= 500)

{
my.visible = off;
wait(1);
}


if(my.clipped != on && vec_dist(my.x,player.x) >= 501)
{
my.visible = on;
wait(1);
}


}


}




I want to make the entity invisible when so close to it. But I get an endless loop on run in my action I've also tried using:


ACTION clip_models {

my.shadow = off;//casts a shadow
my.gravity = off;//gravity off or your tree might float away
wait(1);


while(1)
{


if(my.clipped != on && vec_dist(my.x,player.x) <= 500)

{
my.visible = off;
wait(1);
}


else
{
my.visible = on;
wait(1);
}


}


}