#barrage doesnt hit after 2 seconds

1 messages · Page 1 of 1 (latest)

tropic elbow
#

This is the script:
function data:damage(ability)
self.active.hit = {}
self.active.damageloop = game.RunService.Heartbeat:Connect(function()
for _,child in pairs(workspace:GetPartsInPart(self.active.hitbox)) do
if child.Parent:FindFirstChild("Humanoid") then
if not self.active.hit[child] then
self.active.hit[child] = os.clock()
child.Parent.Humanoid:TakeDamage(1)
else
if os.clock()-self.active.hit[child] >= ability.interval then
self.active.hit[child] = os.clock()
child.Parent.Humanoid:TakeDamage(1)
end
end
end
end
end)
end

it goes far longer than that but its too much. I dont understand why it just breaks sometime. Either the if check fails, or child becomes nil or something??? please help