**this** was nullptr exception, but it isnt?

Hey, so I have my GameInstance and a custom class. I spawn my custom class, and I then let my game instance know about the new object:

	UPROPERTY(BlueprintReadWrite)
		UWSSpawnItems* ItemSpawner;
	GameInst = Cast<UWSGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()));
	ItemSpawner = NewObject<UWSSpawnItems>();
	ItemSpawner->Init();
	GameInst->ItemSpawner = ItemSpawner;

If I print ItemSpawner from my gameInst, it works fine, giving me the object in question:
2023-02-11 20_22_20-Winstick Preview NetMode_ Standalone 0  (64-bit_D3D Shader Model 6)
(However, I noticed that it spawns an additional one each time I start the game in editor? Shouldn’t the game instance reset?)

But as soon as I try to make use of it:

if (IsValid(ItemSpawner))
{
  GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString("New Loadout unlocked!"));
}

It crashes with a “**this** was nullptr

Even IsValid or != nullptr isn’t safe somehow?

Hard to tell what is going on without more context.
I do know that game instance will not always be valid in editor.
Made that mistake before :expressionless:

FIgured it out in the end, looks like GetWorld->GetGameInstance wasn’t as universal as I thought, I had to pass the reference directly through a function instead.