script that plays random sound every minute

I need help with a script that plays random sound every minute.
Im still a real LUA noob

Here’s the Code I hope you can help me.

function playscary(ply)
ply:EmitSound(“ambient/creatures/town_muffled_cry1.wav, ambient/creatures/town_child_scream1.wav, ambient/creatures/town_moan1.wav, ambient/creatures/town_scared_breathing1.wav, ambient/creatures/town_scared_breathing2.wav”)
timer.Create( “soundemmit”, 60, 0, playscary)

I’m new to Lua as well but I thought I would give you some help, I think the thing you need to do is first to have a couple of small fixes. I’m pretty sure you can’t play use EmitSound on players, they should be used on entities.

Try surface.PlaySound

You would also probably want to use a loop as well.

[LUA]function playscary(ply)
y = y + 1;
for k, ply in pairs(player.GetAll()) do
if (y == 0) then
elseif (y == 1) then
elseif (y == 2) then
elseif (y == 3) then
elseif (y == 4) then
timer.Create( “soundemmit”, 60, 0, playscary())
y = 0;[/LUA]

thank you very much. btw in wich folder in autorun do I have to put this in?

You made few mistakes here.

That’s not random.
**[surface.PlaySound](** is a clientside function and you used it in serverside script.
You didn’t localized function and variable.
And you gave result instead of function to timer.

So there is proper script
[lua]local tab = {

local function ScarySounds()
local sound, plytab = table.Random(tab), player.GetAll()
for k = 1, #plytab do
plytab[k]:SendLua(“surface.PlaySound(”"… sound …"")")

timer.Create(“ScarySoundsEmit”, 60, 0, ScarySounds)[/lua]

Put it in your autorun/server folder

Thanks it worked!