# Sound not being replicated

**URL:** <https://forums.unrealengine.com/t/sound-not-being-replicated/749316>\
**Category:** Programming & Scripting\
**Tags:** Replication, play-sound-at-locati, unreal-engine, question\
**Created:** [January 14, 2023, 4:50pm UTC](https://forums.unrealengine.com/t/sound-not-being-replicated/749316 "2023-01-14T16:50:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marquez02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Marquez02](https://forums.unrealengine.com/u/Marquez02)\
**Post date:** [January 14, 2023, 4:50pm UTC](https://forums.unrealengine.com/t/sound-not-being-replicated/749316/1 "2023-01-14T16:50:36Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/8/20808257e17769ef173a525f37965e6ffd1a7058.png)  
i hve a function for the fire action and when I press left click it triggers the function but I can hear the sound on the server and not the client idk why  
Any help would be appreciated

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [January 14, 2023, 4:58pm UTC](https://forums.unrealengine.com/t/sound-not-being-replicated/749316/2 "2023-01-14T16:58:37Z")

</div>

To have the sound play on all other players PC’s in the vicinity you need to make you sound effect function a NetMulticast

Example  
in the header the function definition would be

```auto
UFUNCTION(NetMulticast, Unreliable)
void MC_FireFX();

```

And in the cpp file you have the implementation

```auto
void YourClass::MC_FireFX_Implementation(){
  UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation())
}

```

Then in your fire function on the server after spawning your projectile call

```auto
if(Firesound != nullptr){
MC_FireFX(); 
}

```

p.s.  
I set it to unrealiable because it’s usually a non critical effect. If it’s a stealth game then maybe make it releiable

---

<div class="post-metadata">

**Author:** ![Marquez02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Marquez02](https://forums.unrealengine.com/u/Marquez02)\
**Post date:** [January 14, 2023, 5:08pm UTC](https://forums.unrealengine.com/t/sound-not-being-replicated/749316/3 "2023-01-14T17:08:22Z")

</div>

that didnt really work or maybe i did soemthing wrong  
void APlayerCharacter::OnFire\_Implementation()  
{  
if (IsShooting)  
{  
if(Projectile != NULL)  
{  
if(World != NULL)  
{  
if(Bullets != 0 && ReloadingGun == false && HealingPlayer == false && CanShoot == true)  
{  
SpawnRotation = GetControlRotation();

```
				SpawnLocation = ((MuzzleLocation != nullptr) ?
					MuzzleLocation->GetComponentLocation() :
					GetActorLocation()) + SpawnRotation.RotateVector((GunOffset));
				
				Bullets -= 1;
				IsShooting = true;
				FActorSpawnParameters ActorSpawnParams;
				ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;
				World->SpawnActor<AProjectile>(Projectile, SpawnLocation, SpawnRotation, ActorSpawnParams);
				UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
        
				if(FireSound != nullptr){
					OnFire();
				}
        
				if(FireAnimation != NULL && AnimInstance != NULL)
				{
					UAnimInstance* AnimInstance1P = HandsMesh->GetAnimInstance();
					if(AnimInstance1P != NULL)
					{
						AnimInstance1P->Montage_Play(FireAnimation, 1.0f);
					}

					//UAnimInstance* AnimInstance3P = Mesh3P->GetAnimInstance();
					//if(AnimInstance3P != NULL)
					//{
					//AnimInstance3P->Montage_Play(FireAnimation3P, 1.0f);
					//}
				}
				if(CurrentWeapon->GetWeaponID() == 1)
				{
					World->GetTimerManager().SetTimer(FireTimerHandle, this, &APlayerCharacter::OnFire, CurrentWeapon->FireRate, false);
				}
				else
				{
					IsShooting = false;
					FireTimerHandle.Invalidate();
				}
				
				World->GetTimerManager().SetTimer(FireTimerHandle, this, &APlayerCharacter::OnFire, CurrentWeapon->FireRate, false);
			}
		}
	}
}

```

}  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/1/bd1b178ea2ee0d42efa28027611757cdb1ba2959.png)

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [January 14, 2023, 5:10pm UTC](https://forums.unrealengine.com/t/sound-not-being-replicated/749316/4 "2023-01-14T17:10:42Z")

</div>

The netmulticast function is only supposed play the sound and maybe add muzzle flash. The rest of the logic should be on a normal server function.

---

<div class="post-metadata">

**Author:** ![Marquez02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Marquez02](https://forums.unrealengine.com/u/Marquez02)\
**Post date:** [January 14, 2023, 5:12pm UTC](https://forums.unrealengine.com/t/sound-not-being-replicated/749316/5 "2023-01-14T17:12:58Z")

</div>

ohhh got it  
let me try it

---

<div class="post-metadata">

**Author:** ![Marquez02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Marquez02](https://forums.unrealengine.com/u/Marquez02)\
**Post date:** [January 14, 2023, 5:17pm UTC](https://forums.unrealengine.com/t/sound-not-being-replicated/749316/6 "2023-01-14T17:17:51Z")

</div>

that worked thank you so much
