Either erase the foundation from each edge manually before making a GIF, then save the picture as GIF or PNG to protect straightforwardness, JPG won’t work, or on the other hand, if your GIF has a strong variety foundation, use the effects tool and select “Replace color with transparency” option.