function InfiniteDamageOverTime(victim, dps)
if victim and victim.Parent and victim.Parent.Torso and victim.Parent.Head then
if victim and victim.Parent and victim.Parent:FindFirstChild('Humanoid') then
for i=1, math.huge do
if victim and victim.Parent and victim.Parent.Head and victim.Parent.Torso and victim.Parent:FindFirstChild('Humanoid') then
if victim.Parent:FindFirstChild('Type') then
if victim.Parent.Type.Value == 'Miniboss' or victim.Parent.Type.Value == 'Boss' then
victim.Parent.Humanoid:TakeDamage((dps / 10) * 0.8)
else
victim.Parent.Humanoid:TakeDamage(dps / 10)
end
else
victim.Parent.Humanoid:TakeDamage(dps / 10)
end
wait(.1)
end
end
end
end
end
This is my damage over time coroutine adapted from my one that has a duration / wears off. For my new shotgun, I needed a version of it with infinite duration which is seen here. It works as expected (continuously drains the enemy's health), but if the enemy is killed Studio crashes. Why would that happen?
