# Ability not activating in client ; Effects not applied in client

**URL:** <https://forums.unrealengine.com/t/ability-not-activating-in-client-effects-not-applied-in-client/1642163>\
**Category:** C++\
**Tags:** Ability-System, unreal-engine, Gameplay-Ability-System, question\
**Created:** [January 25, 2024, 7:32pm UTC](https://forums.unrealengine.com/t/ability-not-activating-in-client-effects-not-applied-in-client/1642163 "2024-01-25T19:32:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bennur\_1206](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bennur\_1206](https://forums.unrealengine.com/u/bennur_1206)\
**Post date:** [January 25, 2024, 7:32pm UTC](https://forums.unrealengine.com/t/ability-not-activating-in-client-effects-not-applied-in-client/1642163/1 "2024-01-25T19:32:56Z")

</div>

I have the following base-character, base player-controller and ABILITY\_SYSTEM\_COMPONENT classes.

Abilities and starting effects are not being initialized in the client. It does happen on the server.

So technically, a server has his attributes updated and can activate abilities. But client is unable to have his attributes updated, nor is able to cast any ability.

Base Character:

```auto
void AChar::PossessedBy(AController* NewController)
{
	Super::PossessedBy(NewController);

	ABILITY_SYSTEM_COMPONENT->InitAbilityActorInfo(this, this);

	SetOwner(NewController);

	// initializing starting abilities and effects 
	ABILITY_SYSTEM_COMPONENT->initialize_ASC();
	
}

```

Player Controller:

```auto
// Happens in the client
void Abase_player_controller::AcknowledgePossession(APawn* P)
{
	Super::AcknowledgePossession(P);

	ACHAR * char_ = Cast<ACHAR>(P);

	char_->GetAbilitySystemComponent()->InitAbilityActorInfo(char_, char_);
}

```

My class - UABILITY\_SYSTEM\_COMPONENT, sub-classed from UAbilitySystemComponent:

```auto
void UABILITY_SYSTEM_COMPONENT::initialize_ASC()
{
	if (GetOwnerRole() != ROLE_Authority) return;

	initialize_abilities();

	initial_effects();
}

void UABILITY_SYSTEM_COMPONENT::initialize_abilities()
{
	for (const auto & pair_ : __char->ability_container)
	{
		if ( !(
			pair_.Value &&
			pair_.Key.IsValid()
		) ) continue;

		FGameplayAbilitySpec ability_spec_ = FGameplayAbilitySpec(pair_.Value, 1);

		GiveAbility(ability_spec_);
	}

	b_initial_abilities_provided = true;
}

// __char in an Actor of the class ACHAR that has 
// An input-tag - ability class map.

void UABILITY_SYSTEM_COMPONENT::initial_effects()
{
	if (!__char) return;

	for (const auto & effect_class_ : __char->initial_effect_container)
	{
		FGameplayEffectContextHandle current_effect_context_handle_;
		current_effect_context_handle_.AddSourceObject(this);

		FGameplayEffectSpecHandle current_effect_spec_handle_ = MakeOutgoingSpec(
			 effect_class_,
			 __char->level,
			 current_effect_context_handle_
		);

		ApplyGameplayEffectSpecToSelf(
			*current_effect_spec_handle_.Data.Get()
		);

	}

	b_initial_effects_applied = true;
}

// __char also has a TArray of starting effect classes

```

Interestingly, upon using a breakpoint at the time of button activation of the ability,  
in the client, I see that there are absolutely no abilities granted!

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/b/6fb3aed45e8681ebcf143cfe706964be8ddcf70c.png)

Rather the server has abilities granted.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/b/4/cb40b49607fe2b42228485cef44882a670631f2b.png)

The property - number of activatable abilities, in the ASC shows 11 abilities in Server, but 0 in client!

What is the issue? How to resolve?

And also, should I continue to use GAS or should I build my own inspired by GAS?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![bennur\_1206](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bennur\_1206](https://forums.unrealengine.com/u/bennur_1206)\
**Post date:** [January 26, 2024, 7:30pm UTC](https://forums.unrealengine.com/t/ability-not-activating-in-client-effects-not-applied-in-client/1642163/2 "2024-01-26T19:30:27Z")

</div>

I managed to resolve it myself.

I did an Authority check, and committed the ability only on server, not on client.

Now, gameplay ability was correctly committed once by the server, and attribute value changed appropriately.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 25, 2024, 7:31pm UTC](https://forums.unrealengine.com/t/ability-not-activating-in-client-effects-not-applied-in-client/1642163/3 "2024-02-25T19:31:13Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
