Surface sound Questions

I use this to play music when something like lr happens. How do i make it so it selects a random song from a list or songs

for k,v in pairs(player.GetAll()) do

This is what i currently use. Would the new one be

for k,v in pairs(player.GetAll()) do
v:SendLua("surface.PlaySound(table.Random( songs ))")

songs= { “sound/lrsong2.mp3”, “sound/lrsong1.mp3”, “sound/lrsong3.mp3” }

local songs= { "sound/lrsong2.mp3", "sound/lrsong1.mp3", "sound/lrsong3.mp3" }
BroadcastLua(Format([[surface.PlaySound("%s")]], table.Random(songs)))

local songs= { “sound/lrsong2.mp3”, “sound/lrsong1.mp3”, “sound/lrsong3.mp3” }
for k,v in pairs( player.GetAll() ) do
’" … table.Random( songs ) … "’

[editline]29th July 2015[/editline]

Note that SendLua or BroadcastLua wont work for long file names.

[editline]29th July 2015[/editline]

You are better off by transmitting something like BroadcastLua(“g_PlaySomeShit()”)

and then adding a function like this on client:

function g_PlaySomeShit()
local songs = { "sound/lrsong2.mp3", "sound/lrsong1.mp3", "sound/lrsong3.mp3" }
surface.PlaySound( table.Random( songs ) )

Additionally, you won’t get this shit from me but some people will berate you for using RunString. I feel like you’re perfectly okay using it in this situation, but do know that in the past there have been exploits of RunString. You might want to take this opportunity to try messing around with the Net library to gain knowledge for future scripts but it’s entirely up to you; I’m just telling you that generally the community here avoids RunString.