freeze physics sign for moving с++

I need to change the physics of the object when calling one function.
all classes of the items themselves are inherited from the parent.
I get RootComponent ->GetChildren Components on On Construction
and I pass the array to the for(auto& By Item : Array) function. the loop itself is not called.
checked the debug , everything before the loop is called the loop itself is not.
if you get RootComponent - >GetChildrenComponents (true, Array); in the freeze function itself, it does not initially see physical objects, but it does not transmit physical objects perfectly

for(auto& ByItem : Array) { UMeshComponent* Mesh = Cast<UMeshComponent>(ByItem); if (Mesh) { GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, FString::Printf(TEXT(“InLoop”))); Mesh->SetSimulatePhysics(!InputFreeze); } } This is the freeze function itself. What could be the error? or how can it be done differently?