Trying to figure out why this script won't stop the damage when enemy is dead. The enemy continues to deal damage through his limps on the ground after he is dead (I believe it is just the torso).
local canhit = true
local enemytorso = script.Parent:FindFirstChild('Torso')
if enemytorso and script.Parent.Enemy.Health > 0 then
enemytorso.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
if canhit then
canhit = false
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
wait(1)
canhit = true
end
end
end)
end
