"Sound.Play" Help

I’m trying to make a weapon which acts as a sound-transmitter, playing a sound to the players that are surrounding wherever you click.

The problem is that only the player using the weapon can hear the sound, other players can’t.

The function I am using for this is:


function SoundGun(csound)

		local trace = self.Owner:GetEyeTraceNoCursor()
		local hpos = trace.HitPos
		local ppos = self.Owner:GetPos()
		
		if trace.HitNonWorld == false then
			if trace.Hit == true then
				sound.Play(csound, hpos)
				
			end
		end
	end

The parameter “csound” is the path to the sound, and “hpos” is the entity that is hit.

It would be amazing if someone could help me fix this problem! :slight_smile:

Are you calling it serverside or clientside?

Use EmitSound instead.

In Entity/Emitsound cannot be set possition.

I’m calling it in my shared.lua

If I need to call it serverside , how would I keep the HitPos value?

The entity calling it will be the origin, use G/EmitSound instead if you are playing with 5:1 or 7:2 and must have the sound origin from an exact vector

It doesn’t seem to play anything, no errors in console either.


	function SoundGun(csound)

		local trace = self.Owner:GetEyeTraceNoCursor()
		local hpos = trace.HitPos
		local ppos = self.Owner:GetPos()
		local mrowner = self.Owner
		
		if trace.HitNonWorld == false then
			if trace.Hit == true then
				EmitSound(csound, hpos, 1, 3, 1, 1, 1, 75)
				
			end
		end
	end

Change soundlevel and volume to something WAY higher. 1 is basically lowest possible, i think volume goes all the way up to 254 or 255 and soundlevel up to 511 or something.