# GAS system | WaitGameplayEvent stops working after some time

**URL:** <https://forums.unrealengine.com/t/gas-system-waitgameplayevent-stops-working-after-some-time/2240486>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [December 24, 2024, 4:26pm UTC](https://forums.unrealengine.com/t/gas-system-waitgameplayevent-stops-working-after-some-time/2240486 "2024-12-24T16:26:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GhostDeveloper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GhostDeveloper](https://forums.unrealengine.com/u/GhostDeveloper)\
**Post date:** [December 24, 2024, 4:26pm UTC](https://forums.unrealengine.com/t/gas-system-waitgameplayevent-stops-working-after-some-time/2240486/1 "2024-12-24T16:26:33Z")

</div>

Hello! I get an issue and dont understand why it happens, i have a passive gameplay ability for receiving some gameplay events like incoming exp and etc. But i found, that after some seconds the method  
“UAbilityTask\_WaitGameplayEvent::WaitGameplayEvent” stopped receiving data, my code for passive ability:

```auto
void UPwPassiveAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle,
                                      const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo,
                                      const FGameplayEventData* TriggerEventData)
{
	Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);
	
	UAbilityTask_WaitGameplayEvent* GameplayEvent = UAbilityTask_WaitGameplayEvent::WaitGameplayEvent(
		OwningAbility, EventTag, OptionalExternalTarget, OnlyTriggerOnce, OnlyMatchExact);
	GameplayEvent->EventReceived.AddDynamic(this, &UPwGameplayAbility::OnGameplayEventReceived);
	GameplayEvent->Activate();
}

void UPwPassiveAbility::OnGameplayEventReceived(FGameplayEventData Payload)
{
	Super::OnGameplayEventReceived(Payload);
	
	if (Payload.EventTag.MatchesTag(FPwGameplayTags::Get().Attributes))
	{
		const UAbilitySystemComponent* SourceASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(GetAvatarActorFromActorInfo());
		const FGameplayEffectSpecHandle EffectSpecHandle = SourceASC->MakeOutgoingSpec(EffectClass, GetAbilityLevel(), SourceASC->MakeEffectContext());
		UAbilitySystemBlueprintLibrary::AssignTagSetByCallerMagnitude(EffectSpecHandle, Payload.EventTag, Payload.EventMagnitude);
		GetAbilitySystemComponentFromActorInfo()->ApplyGameplayEffectSpecToSelf(*EffectSpecHandle.Data.Get());
	}
}

```

I debugging AbilitySystem inside unreal engine by “showdebug abilitysystem” command, passive ability is active!

Code for sending incoming experience event:

```auto
const FPwGameplayTags& GameplayTags = FPwGameplayTags::Get();
		FGameplayEventData Payload;
		Payload.EventTag = GameplayTags.AttributesMetaIncomingExp;
		Payload.EventMagnitude = ExpReward;
		
		UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(Props.SourceCharacter, GameplayTags.AttributesMetaIncomingExp, Payload);

```

**UPDATE:** Garbage collector removed ‘GameplayEvent’ object, need to create a member variable and all works as expected now!
