your first while loop is endless , the function will never reach the second while loop so its pointless to have it.
If I understand what this function does , if you move the model you attached the function to you'll move the fog too. So , before the code after "while(1) {" put my.x = player.x; my.y = player.y and my.z = player.z; and it'll move with the player. You could also put it before wait(1); if there are problems.