Another unreasonable lua error.

I am trying to create a new SNPC, in this particular error, i am trying to add an automatic musical theme which starts upon the spawn of the SNPC…

This is the error i am constantly recieving no matter what i do, on line 35 of the SNPC code, there is supposed to be a “(” near “self” and no matter where i place it, it refuses to work properly.

 function ENT:OnSpawn
  self:(CreateSound = "npc/godzilla/Theme.mp3")

there is the code, that is’nt the original, and seriously, i’ve attempted to place brackets everywhere, nothing seems to work… so if you understand how to resolve this, i’d like to know!

Honestly, how do you expect that code to work?

[editline]…[/editline] I’ve no clue how to play the sound, but I can tell you this:
“Near ‘self’” means it must be either before or after self, not one character away.

I guess pepper has his shitposting day today, anyway, go read the Lua-PIL again.

Create an usermessage hook in cl_init.lua:

usermessage.Hook("PlayGodzillaTheme", function()

Place this in your entity’s init.lua:

function ENT:Initialize()

Edit: In fact, try placing this in the entity’s cl_init.lua instead:

function ENT:Initialize()

There is a difference between CreateSound and surface.PlaySound.

Alright alright:

soundFile = Sound("npc/godzilla/Theme.mp3")
function ENT:Initialize()
	local sound = CreateSound(self, soundFile)

Won’t work either, the sound will get purged because it’s not referenced anymore, you need to save it in the entity.

What about
function ENT:Initialize()
local self.sound = CreateSound(self, Sound(“npc/godzilla/Theme.mp3”))

That would work right ?

That would give you a syntax error lol.

Not having to deal with the fact that your sounds aren’t working… I haven’t seen anybody point out that his ENT:OnSpawn has no () after it…