Stopping a sound after a set delay

Here’s what I’m doing :

local ExplosionSound = CreateSound(self.Entity, Sound("Weapon_StriderBuster.Detonate"))
//timer.Simple(1.2, ExplosionSound:Stop())

The problem is when I don’t comment out the timer the sound won’t even start and I get "
Timer Error: attempt to call a nil value". Does anyone know what I’m doing wrong? :confused:

[lua]timer.Simple(1.2, function() ExplosionSound:Stop() end)[/lua]

That would normally work but the entity I’m playing the sound on is destroyed before the sound has to be stopped. It seems to make stopping the sound that way impossible.

Instead of removing the entity straight away can you not nodraw it and then in the timer remove the entity properly once you end the sound. That way you can use Stop() for the sound.

I don’t know why but I was thinking of making a dummy entity just for it, your idea is much better, thanks. :wink: