Spawning an actor in C++ on a client causes crash

I’m trying to spawn a local actor on the client that doesn’t replicate. I’m using GetWorld()->SpawnActor, but it crashes
in PostSpawnInitialize at check(Role == ROLE_Authority) with this error: Assertion failed: Role == ROLE_Authority.

I manually set the role to ROLE_Authority and it works now. Thanks!

Looking into the code within PostSpawnInitialize it appears that the check is making sure that the local machine has the proper flags set to have authority over the spawned actor.

If you’re spawning an actor locally on a machine then you need to set its Role to ROLE_Authority to signify that it can be modified by the local machine.

This variable is by default set to ROLE_Authority, but its possible that the spawn parameters could be changing this.