What using AttachToComponent C++?

WeaponRef->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::SnapToTargetIncludingScale);

This code causes the engine to crash. Help!

If the engine crashes, then you’re probably trying to reference a nullptr.

What’s WeaponRef? Do you assign a value to it somehow?

Thanks, my WeaponRef was actually set to null.