Source/BattleRoyale/core/Character/CharacterBase.cpp
//Only server can give abilities.
Only server can give abilities.
Only server can give abilities .
void ACharacterBase::GiveAbilitiesServer()
{
	if(!HasAuthority())
	{
		return;
	}
	const auto playerState = GetPlayerStateInterface();
	if(playerState)
	{
		const auto abilitySystemComponent = playerState->GetAbilitySystemComponent();
		if(abilitySystemComponent)
		{
			for(TSubclassOf<UGameplayAbilityBase>& startupAbility : mDefaultAbilities)
			{
				abilitySystemComponent->GiveAbility(
					FGameplayAbilitySpec(startupAbility, 1, static_cast<int32>(startupAbility.GetDefaultObject()->AbilityInputID), this)
				);
			}
		}
	}	
}
void ACharacterBase :: GiveAbilitiesServer ( ) { if ( ! HasAuthority ( ) ) { return ; } const auto playerState = GetPlayerStateInterface ( ) ; if ( playerState ) { const auto abilitySystemComponent = playerState -> GetAbilitySystemComponent ( ) ; if ( abilitySystemComponent ) { for ( TSubclassOf < UGameplayAbilityBase > & startupAbility : mDefaultAbilities ) { abilitySystemComponent -> GiveAbility ( FGameplayAbilitySpec ( startupAbility , 1 , static_cast < int32 > ( startupAbility . GetDefaultObject ( ) -> AbilityInputID ) , this ) ) ; } } } }
Only server can give abilities.
Only server can give abilities .
//Asign abilities to the ability system component. As Ability system component is replicated, we are //asigning also to the clients.