After three times the hitbox stop hitting

i made a continuing dmg hitbox, which always stops after the 3d time it does dmg
thanks in advance

spawn(function()
		ultPart.Hitbox.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("NPCHumanoid")
			if hum and hum.Parent.TakeDMG.Value == false then
				print("hi")
				hum.Parent.TakeDMG.Value = true
				local build = 0
				repeat 
					task.wait(0.5)
					build += 1
					hum:TakeDamage(10)
				until build == 1
				hit.TouchEnded:Connect(function() hum.Parent.TakeDMG.Value = false print ("bye") end)
				build = 0
			end
		end)	
	end)
1 Like

if you want to make a continuing hitbox then i’d suggest you use Workspace:GetPartsinPart instead, (also never use touched for hitboxes, it’s terrible)

local hitamount = 10
local hitcooldown = 0.1

local overlapparams = OverlapParams.new()
overlapparams.FilterType = Enum.RaycastFilterType.Exclude
overlapparams.FilterDescendantsInstances = {player.Character}

for i = 0, hitamount do
    task.spawn(function()
        for i,v in pairs(workspace:GetPartsInPart(ultPart, overlapparams)) do
            if v.Name == "HumanoidRootPart" and v.Parent:FindFirstChild("NPCHumanoid") then
                hum:TakeDamage(10)
            end
        end
    end)
    task.wait(hitcooldown)
end
2 Likes

tried that, still doesnt work, no errors or somthin but just does nothing…

1 Like

did you modify the code in any way…?

1 Like

not at all! unfortunately it didnt work, i tried to print v too, and it didnt show anything

1 Like

that’s really odd… it should’ve worked? try this

local hitamount = 10
local hitcooldown = 0.1

for i = 0, hitamount, 1 do
    task.spawn(function()
        for i,v in pairs(workspace:GetPartsInPart(ultPart)) do
            if v.Name == "HumanoidRootPart" and v.Parent:FindFirstChild("NPCHumanoid") then
                v.Parent.NPCHumanoid:TakeDamage(10)
            end
        end
    end)
    task.wait(hitcooldown)
end
2 Likes

thank you so much! it actually does work, the only problem is that i have some issues with the cooldown, it’s charshin roblox studio, i think i might know how to fix it so ill just try to do it myself but thank you very much