UE4 Crashes when editor play as client

I am trying to implement multiplayer

I am using PlayerController class to move my characters.

.cpp:

where i call functions

void ASquadPlayerController::SetupInputComponent()
{
	Super::SetupInputComponent();
	check(InputComponent);

	// Right Joystick Input
	InputComponent->BindAxis("TurnRate", this, &ASquadPlayerController::RotateForward);
	InputComponent->BindAxis("LookUpRate", this, &ASquadPlayerController::RotateYaw);
}

// the functions below here

void ASquadPlayerController::RotateForward(float Value)
{
	// Setting the Control Rotation on Input
	if (Value != 0.0f)
	{
		UGameplayStatics::GetPlayerCharacter(GetWorld(),0)->GetCharacterMovement()->bOrientRotationToMovement = false;
		RotAxisValueX = GetInputAxisValue("TurnRate");
		RotAxisValueY = GetInputAxisValue("LookUpRate");
		ControllerVec.Y = RotAxisValueX;
		ControllerVec.X = RotAxisValueY;
		ControllerRot = UKismetMathLibrary::MakeRotFromX(ControllerVec);
		SetControlRotation(ControllerRot);
	}
	else
	{
		UGameplayStatics::GetPlayerCharacter(GetWorld(),0)->GetCharacterMovement()->bOrientRotationToMovement = false; // change this
		//GetCharacter()->GetCharacterMovement()->bOrientRotationToMovement = true; // this is where exactly crash happens
		UGameplayStatics::GetPlayerCharacter(GetWorld(),0)->bUseControllerRotationYaw = false;
	}
}

and the .h file

	UFUNCTION(BlueprintAuthorityOnly, Category = "Controller")
    void RotateForward(float Value);

	UFUNCTION(BlueprintAuthorityOnly, Category = "Controller")
    void RotateYaw(float Value);

	//Required 
	virtual void SetupInputComponent() override;

–
the crash screen:

UGameplayStatics::GetPlayerCharacter()

This should never be used in Multiplayer. Use GetPawn() instead to access that controllers’ current pawn and cast it.

You also aren’t checking for nullptr, so because the character is null you’re getting a crash. In Multiplayer actors take time to replicate, and therefore won’t be available on the client machine straight away.