• surface.PlaySound() attempt to index global 'surface' (a nil value)
    4 replies, posted
Right now i want to play a Sound once when a Entity of mine gets used, only one time the sound, then never again (until you restart the server or gmod..) And its supposed to be a clientside sound, that only the one player hears who uses the Entity. And according to Gmod Wiki surface.PlaySound is exacly what i need for that. However when i use that, and put in the path to my sound and everything, and then use the entitie, i get a script error saying what the title says. ..i dont really see the sense behind it...
Your script is running serverside, surface doesn't exist on the serverside. Use net library or Entity/EmitSound
well..that didnt do shit ._. now it just says that my Entity is a nil value.. (yes i called it Entity and ENT. tryd both.) ALSO the gmod wiki says the first paremeter is string soundname, while the syntaxc highlight in my sublime says the first parameter is vector...sooo..which one is right? i hope the gmod wiki one since its alot easier and i dont wanna define positions
It should look like function ENT:YourEventName() self:EmitSound("path/to/sound"/*, other arguments*/) end
oh yea i might should have tryd self: ....but i fixed it myself. on a litte other way. idk if its better tho. Its in cl_init and says surface.PlaySound( "tracksterlaboratory/Wtttlrs.mp3" ) and now it works exacly as i want to
Sorry, you need to Log In to post a reply to this thread.