Simple way to play sounds to all players?

How can I set that a player via a menu can activate a sound that the rest of the players can hear?

I tried these:


sound.Play()
player.EmitSound()

But when I try them no sound comes out and no errors either.

[lua]for _,v in pairs(player.GetAll()) do
v:ConCommand(“playsound /path/sound.wav”)
end[/lua]
If playsound doesn’t work try using play.

[editline]wat[/editline]
Why is everybody trying to overcomplicate it besides me?

I created a Derma Menu, making it as a Taunt Menu for Prop Hunt.
I don’t look to make it too complex.

The following code plays the sound to everyone?


surface.PlaySound("Sound/Dir.wav")

[lua]
for _,ply in pairs(player.GetAll()) do
ply:EmitSound(“path/to/sound.whatever”)
end
[/lua]

That will do so that all the players will play the same sound at the same time and other players will hear it

Then you can just do this:
[lua]
for _,ply in pairs(player.GetAll()) do
ply:SendLua[[LocalPlayer():EmitSound(“path/to/sound.whatever”)]]
end
[/lua]

My bad the first will work if you put in a clientside file.

If you want to play music from an URL(MP3) to a person or anyone, you could use this code snippet, and replace the URL in it. (You can use both ply:SendLua(for a single target) and BroadcastLua(for everyone on the server)

[lua]
BroadcastLua(sound.PlayURL(“http://nitrogaming.org/stuff/salsa.mp3”, " ", function(x) end))
– So fun to troll with :wink:
[/lua]