Attaching a SpringArmComponent to a RootComponent

Hello, I’ve recently started to use Unreal Engine and was following this tutorial here

And after placing a variant of their code inside of my own, it compiles fine. But when running the editor I get this error message:

“root component cannot be attached to other components in the same actor”

Here is the block of code I believe is being affected by it

   RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
    testMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TestMesh"));
    OurCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
    OurCameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 50.0f), FRotator(-60.0f, 0.0f, 0.0f));
    OurCameraSpringArm->TargetArmLength = 400.f;
    OurCameraSpringArm->bEnableCameraLag = true;
    OurCameraSpringArm->CameraLagSpeed = 3.0f;

    OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("GameCamera"));
    OurCamera->SetupAttachment(OurCameraSpringArm, USpringArmComponent::SocketName);

I seemed to have solved this problem somehow by reversing what was attached to what, just by changing the line