How to change metallic properties of Material C++

My question is how to change the metallic property of a certain material. But when I seem to change it using c++ it doesn’t actually to show up.

			meshComponent = ActorItr->GetStaticMeshComponent();
			materialInstance = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), NULL, *currentMaterialPath));
			input.Constant = 1.0;
			input.UseConstant = 1.0;
			materialInstance->Metallic = input;

			dynamicMaterial = UMaterialInstanceDynamic::Create(materialInstance, this);

			FScalarMaterialInput te2 = materialInstance->Metallic;
			float num = te2.Constant;
			FString tent = FString::SanitizeFloat(num);
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, tent);

			meshComponent->SetMaterial(3, dynamicMaterial);