Why do fireflies have light?

To attract a mate.