I can't figure out why.
[CODE]
function ENT:OnTakeDamage(dmg)
--print(dmg:GetDamage())
self.Damage = self.Damage - dmg:GetDamage()
if self.Damage <= 0 then
Explode()
end
end
[/CODE]
It is initialized.
[CODE]self.Damage = 50[/CODE]
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]
[QUOTE=Kuro Light;43792117]Try adding self: infront of explode.[/QUOTE]
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
[IMG]http://i.snag.gy/0qqOi.jpg[/IMG]
And this is the init.lua
[IMG]http://i.snag.gy/hTZkh.jpg[/IMG]
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.
Sorry, you need to Log In to post a reply to this thread.