Emit sound to player only

Right now i use EmitSound but other players can hear it.
Does it exist anouther command that only plays it to the entity i choose?

AFAIK the only way is to use **[Surface.PlaySound

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Surface.PlaySound)** client side on the player.

so i do it like this? ply.PlaySound() ?


It is clientside, so you may have to send a usermessage to the client telling it to play the sound.


Or you could use **[Player.SendLua

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.SendLua)**. (I don’t recommend it)


function _R.Player:PlaySound(path)


the resource.AddFile bit is important.

yeah i know i already have it on the server sending it to people

Well then you should use surface.PlaySound().


Misread problem.


self:EmitSound(“soundname.wav”, 100, 100)
In side the quotes is the name of your sound, if its just in the sound folder, then just put the name of it where with the file type. If its in another folder inside the sound folder then, soundfolder/soundname.wav.
the 100, 100 is the volume and pitch from the original. 100 means to have it not changed. the first 100 is the volume.

Bad reading, he said he is using that already but wants to make it so only a single player hears the sound.

It’s self, so only that person will hear it. He’s just using EmitSound

I’m pretty sure EmitSound doesn’t even work clientside.


And if it does, I take back what I said.


Also, it doesn’t matter if you do it on self, that just means that the sound will come from the player, other players near by will still be able to hear it. (if it is serverside)

Look. When your calling EmitSound, it will come from the Entity or whatever is calling it. Like a swep. You use EmitSound to let everyone hear it. self:EmitSound to just emit it so you hear it.

EmitSound is a method in the entity metatable, which means that it is available to players as well, calling it on a player is just like calling it on any other entities, it will emit the sound from that entity, and people in a certain radius will hear it.

Im using ply:EmitSound() and its like NullPoint sais

Could you post the code and say whether it is client or server please?

i have it in a shared file that both server and client uses.
So im going to try the code later

EmitSound is shared.

I know. I’m not sure if it actually works on the client though.

Yeah it will because it’s shared so it will work on Both Client and Server, or in a shared file.