Dust coagulation in star formation with different metallicities