CreatePlayer after RemovePlayer crashes the editor

(source build 4.11.0)

Creating this thread to report a new problem as requested in RemovePlayer not working on client - Blueprint - Unreal Engine Forums

I tried the workaround described in the thread above and it worked, but I ran into other two issues:

1 - The code of your workaround did not work on the server, but it worked after I put 2 as player index in GetPlayerController, so it seems that the newly created player takes index 2. Maybe this is not exacly an issue, but I wonder why this happens.

2 - Using your code on the client, re-running CreatePlayer after running RemovePlayer crashes the editor with this message:

Fatal error: [File:E:\UE4\UnrealEngine\Engine\Source\Runtime\Engine\Private\NetConnection.cpp] [Line: 1712] Failed to find LocalPlayer for received PlayerController

To avoid misunderstandings, this is the code:

88057-create_player_crash.png

To reproduce run pie and in the client press F and then G.

Hello matfer,

I was able to reproduce this issue on our end. I have written up a report ( UE-29969) and I have submitted to the developers for further consideration. I will provide updates with any pertinent information as it becomes available. Thank you for your time and information.

Make it a great day

I am also having this issue on UE 4.23 - was this looked into? Is there any current workaround?

This is the output I’m getting:
LogNet: Error: Failed to find LocalPlayer for received PlayerController ‘PlayerControllerVRJPG_C_3’ with index 3. PlayerControllers:
LogNet: - PlayerControllerVRJPG_C /Game/Maps/UEDPIE_3_Default.Default:PersistentLevel.PlayerControllerVRJPG_C_0
LogNet: - PlayerControllerVRJPG_C /Game/Maps/UEDPIE_3_Default.Default:PersistentLevel.PlayerControllerVRJPG_C_1
LogNet: - PlayerControllerVRJPG_C /Game/Maps/UEDPIE_3_Default.Default:PersistentLevel.PlayerControllerVRJPG_C_2
LogNet: - PlayerControllerVRJPG_C /Game/Maps/UEDPIE_3_Default.Default:PersistentLevel.PlayerControllerVRJPG_C_3
LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr: 127.0.0.1:17777, Name: IpConnection_25, Driver: GameNetDriver IpNetDriver_20, IsServer: NO, PC: PlayerControllerVRJPG_C_0, Owner: PlayerControllerVRJPG_C_0, UniqueId: NULL, Channels: 84, Time: 2020.05.16-03.35.34
LogNet: UChannel::Close: Sending CloseBunch. ChIndex == 0. Name: [UChannel] ChIndex: 0, Closing: 0 [UNetConnection] RemoteAddr: 127.0.0.1:17777, Name: IpConnection_25, Driver: GameNetDriver IpNetDriver_20, IsServer: NO, PC: PlayerControllerVRJPG_C_0, Owner: PlayerControllerVRJPG_C_0, UniqueId: NULL
LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionLost, ErrorString = Your connection to the host has been lost., Driver = GameNetDriver IpNetDriver_20
LogNet: Warning: Network Failure: GameNetDriver[ConnectionLost]: Your connection to the host has been lost.
LogNet: NetworkFailure: ConnectionLost, Error: ‘Your connection to the host has been lost.’