Why isn't my entity taking damage?

I can’t figure out why.




function ENT:OnTakeDamage(dmg)
	--print(dmg:GetDamage())
	self.Damage = self.Damage - dmg:GetDamage()

	if self.Damage <= 0 then 
	Explode()
	end

end



It is initialized.


self.Damage = 50

Kind of nitpicky but Damage is kind of a backwards name for what your doing, I personally would use Health as the name.

Also is the OnTakeDamage hook even running? From what you’ve put down I presume it runs but never decreases the Damage variable? Any errors in console? From what you’ve given us everything seems fine but there must be something missing.

Try adding self: infront of explode.

I haven’t seen any errors.
It doesn’t seem to interact with ENT:Use() either.

Well, i’ll just have to look harder.

[editline]5th February 2014[/editline]

Good idea, I tried it. But I think the problem has something to do with the entity not being able to be interacted with because the print(dmg) is never executed. Same with ENT:Use(). for some reason I can’t work with the entity.

What’s the shared.lua where you define the entity type?

This is the shared.lua

http://i.snag.gy/0qqOi.jpg

And this is the init.lua

http://i.snag.gy/hTZkh.jpg

What does your function Explode even do? I don’t think Explode() is a standard Garry’s Mod Function.

It’s a function that does an explosion effect then removes the entitiy.