# Correct way to replicate Event

**URL:** https://qa.fmod.com/t/correct-way-to-replicate-event/20837
**Category:** Unreal Engine
**Tags:** ue4, cpp
**Created:** [November 3, 2023, 12:15am UTC](https://qa.fmod.com/t/correct-way-to-replicate-event/20837 "2023-11-03T00:15:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![leejewitt](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leejewitt/32/3910_2.png) [@leejewitt](https://qa.fmod.com/u/leejewitt)
#### Post date: [November 3, 2023, 12:15am UTC](https://qa.fmod.com/t/correct-way-to-replicate-event/20837/1 "2023-11-03T00:15:36Z")

</div>

I am struggling to Get my event to stop every time on my weapons this is what i have implemented.

Mouse pressed starts weapon fire and mouse released stops fire.

weapon executes Fire();  
that contains PlayWeaponFireAudio();

function checks if IsLocallyControlled and sets event to 1P or 3P on result

i then only set instance and play if instance is not valid as its a looping event

```auto
if(!EventInstance.Instance->isValid())
		{
			EventInstance = UFMODBlueprintStatics::PlayEventAtLocation(GetWorld(), CurrentFireEvent, GetActorTransform(), true);
		}
		UFMODBlueprintStatics::EventInstanceSetTransform(EventInstance, GetActorTransform());

```

i then use the same function in the MutiFire();

then when mouse is released i execute StopLoopedWeaponFireAudio()

i stop it locally with

```auto
UFMODBlueprintStatics::EventInstanceStop(EventInstance, true);
	EventInstance.Instance = nullptr;

```

then run a server event that calls a multicast to stop the event with

```auto
UFMODBlueprintStatics::EventInstanceStop(EventInstance, true);
	EventInstance.Instance = nullptr;

```

can anyone see any issues with the way i am doing it?

EventInstance is replicated

```auto
void AProjectileWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	
	DOREPLIFETIME(AProjectileWeapon, EventInstance);
	
	
	
}

```

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [November 7, 2023, 11:31pm UTC](https://qa.fmod.com/t/correct-way-to-replicate-event/20837/2 "2023-11-07T23:31:18Z")

</div>

Hi,

What version of the FMOD integration are you using?

To stop an event you will need to call `EventInstance::Stop()` which may be missing from your `EventInstanceStop(EventInstance, true);` function. You can read more about the EventInstance functions here: [FMOD Engine | Studio API Reference - EventInstance](https://fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_stop).

I am confused about how replicating an event is involved, could you elaborate a bit further if there is still an issue?

Hope this helps!
