Using Ue4 GAS and GiveAbility causes crash

i have the ability system component and everything

but when i call this it ( returns ) because it has no authority and when i call it with a server function it still crashes

void AShooterCharacter::AddCharacterAbilities()
{
	// Grant abilities, but only on the server	
	if (GetLocalRole() != ROLE_Authority || !IsValid(AbilitySystemComponent) || AbilitySystemComponent->CharacterAbilitiesGiven)
	{
		return;
	}

	int32 InLevel;
	for (TSubclassOf<UGDGameplayAbility>& StartupAbility : CharacterAbilities)
	{
		AbilitySystemComponent->GiveAbility(
			FGameplayAbilitySpec(StartupAbility, (InLevel = 1), static_cast<int32>(StartupAbility.GetDefaultObject()->AbilityInputID), this));
	}
	AbilitySystemComponent->CharacterAbilitiesGiven = true;
}

i am binding the Ability system component like this

	AbilitySystemComponent->BindAbilityActivationToInputComponent(InputComponent, FGameplayAbilityInputBinds(FString("Ability1"), FString("Ability1Cancel"), FString("EGDAbilityInputID"), static_cast<int32>(EGDAbilityInputID::Ability1), static_cast<int32>(EGDAbilityInputID::Cancel)));