Self is nil in my entity's custom function?

When I use the variable ‘self’ inside a custom function I created, it returns nil.
But in the picture below my code it’s possible to use self inside a custom function.

How can I use self in my custom function?



function ENT:Explode()

		print(self)
		
		-- Sample code
		local effectdata = EffectData()
		effectdata:SetMagnitude( 2 )
		effectdata:SetOrigin( self:GetPos() )
		util.Effect( "HelicopterMegaBomb", effectdata )
		
end


Well the ent is a table of data if I’m not mistaken and you have to use the PrintTable function to print it. Someone correct me if I’m wrong.

Thanks but that wasn’t the case.

table expected, got nil

Does the entity exist when you run the function? Are you perhaps removing it before hand?

My mistake. I was calling the function with self.Explode() not self:Explode()



function ENT:OnTakeDamage( dmginfo )

	print(self)
	self.Explode()
			
end

function ENT:Explode(pos)

	print(self)

end