Suicide bomb error?

[lua]
function SWEP:ALLAHAUACKBAR()
local vPoint = playa:GetPos()
local effectdata = EffectData()
effectdata:SetStart( vPoint ) // not sure if we need a start and origin (endpoint) for this effect, but whatever
effectdata:SetOrigin( vPoint )
effectdata:SetScale( 6 )
util.Effect( “Explosion”, effectdata )
playa:Kill()
end

//SWEP:PrimaryFire()\
function SWEP:PrimaryAttack()
playa = self.Owner
if ( !self:CanPrimaryAttack() ) then return end
self.Owner:EmitSound(“npc/dog/dog_laugh1.wav”)
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
timer.Create(“suicide”, 1, 1, self:ALLAHAUACKBAR())
end
//SWEP:PrimaryFire()\
[/lua]

weapons/weapon_flerpsuicide/shared.lua:73: attempt to call method ‘Kill’ (a nil value)
Timer Error: attempt to call a nil value

What am I doing wrong?
I just want it to wait 1 second after pressing attack, then explode.

Currently it explodes immediately.

Umm, I don’t see why this would affect it, but try


timer.Simple(1,function() self:ALLAHAUACKBAR() end)

You mean to say:

[lua]timer.Simple( 1, self.ALLAHAUACKBAR )
[/lua]

No need to create a wrapper function.

[editline]12:07PM[/editline]

Oh by the way, “playa” isn’t defined. This is your root problem. use “self.Owner” instead.

[editline]12:07PM[/editline]

And don’t define it in a separate function.

That magically fixed the timer problem, but there is still the error of 'attempt to call method ‘Kill’ (a nil value)

Yet the player still dies?

I wasn’t sure initially, but is “playa” a global variable established outside of the PrimaryAttack function or is it of a local scope?

He defined it in SWEP.PrimaryAttack as a global, which just shouldn’t be done. It’s unnecessary.

I mean, I understand the scoping issues but it would be valid if he defined playa in a part of the code we can’t see.

I replaced playa with self.Owner, but I still get that error, but it works perfectly fine?

If the error is still calling the method “Kill” on self.Owner… that’s weird. It means something is killing self.Owner, and then you try and kill him again I guess?

Nice racist function name there :C

try doing if (SERVER) then