Surface.PlaySound Causes script errors

Hi there. I am currently working on a highly modified FLOOD server, and today i hit a rock.

I am trying to make a sound play when it is time to get on your boat. Because i wanted everyone to hear the sound, regradless of their position on the map, so i decided to use Surface.PlaySound.

But the problem is that when the sound is supposed to play ingame, i instead get this in my console:



[ERROR] gamemodes/flood13/gamemode/init.lua:284: attempt to index global 'surface' (a nil value)
  1. unknown - gamemodes/flood13/gamemode/init.lua:284


This is the code in init.lua that does the check and plays the sound:



function GM:Think()
        if FloodTime == 9 then
                PrintMessage( HUD_PRINTCENTER, "WARNING! FLOOD INCOMING! GET ON YOUR BOAT!" )
                surface.PlaySound("/ambient/siren.wav")
        end
end


What am i doing wrong?

Thanks

surface is clientside. You’re using it serverside.
And also, you don’t have to put “/” before the path.
If you can’t do networking using the net library, you can do:

[lua]BroadcastLua(“surface.PlaySound(“ambient/siren.wav”)”)[/lua]

I added the slashes before the quotes so that lua “escapes” the quote characters. AKA: Recognises them as a string and not as code.

Thank you! You solved my problem!