Randomly on some servers for my game “Town Defend” several of the monsters seem to be attacking even post-death.
For context, it seems that the sounds do not repeat, however, randomly my orc will still be attacking after death.
It doesn’t always happen, it seems to only occur once in a while. The code is huge, and has multiple sections but if anyone has an idea why there’d be “ghost” monsters within my game “sometimes” what should I do?
I have checked and I can almost confirm it has to be a ghost orc attacking because that’s the only thing within my game with a TakeDamage function.
canDamage = distance <= 5
if (canDamage) then
self.LastDamage = current
if self.Humanoid.Health > 0 then
closestPlayer.humanoid:TakeDamage(self.Damage)
SoundHandler.PlaySound("Orc.attack", rig, {
Volume = 0.8;
PlaybackSpeed = math.random(800, 1200)/1000;
})
self.WalkAnimation:Stop()
self.DanceAnimation:Stop()
self.AttackAnimation:Play()
end