How i can handle a hitbox function with :GetPartsInPart()?

Im doing a new combat system with a hitbox function using “:GetPartsInPart()” but [i think the loop] works really bad
The function never ends so the game starts lagging as hell

im trying to achieve something like this:
https://gyazo.com/a69a47abbe89b4b371584c756c830e57
But i just got this: (the hitbox appears but dont work bc of the lag)
image

This is the function(is inside a server script)

function Hitbox(Character,DMG,STUN,Duration,WeldedPart,Distance,Knockback,Knockback2,Transparency)
        local debounce = false
        print("HITBOX START")
        local HITBOX = script.SWORDHITBOX:Clone()
        HITBOX.Anchored = false
        HITBOX.Parent = Character
        HITBOX.CFrame = Distance --EXAMPLE: Character.HumanoidRootPart.CFrame + Character.HumanoidRootPart.CFrame.LookVector*4
        HITBOX.Orientation = Character.HumanoidRootPart.Orientation + Vector3.new(0,-90,0)
        HITBOX.Transparency = Transparency
        local weld =  Instance.new("WeldConstraint")
        weld.Part0 = WeldedPart
        weld.Part1 =  HITBOX
        weld.Parent =  weld.Part0
        
        function Damage(hit) --ingore this, this is only effects + dmg
        end

        local parts = workspace:GetPartsInPart(HITBOX)
        game:GetService("RunService").Stepped:Connect(function(step)
            wait(0.01)
            for _, v in pairs(parts) do
                print("HITBOX ACTIVE")
                Damage(v)
            end
        end)
        
        wait(Duration)
        game.Debris:AddItem(HITBOX,0)
        print("HITBOX END")
        debounce = false
    end

i try changing the detection part to this:

while HITBOX and task.wait(0.01) do
	for _, v in pairs(parts) do
		print("HITBOX ACTIVE")
		Damage(v)
	end
end

but didnt work
Oh and there is no chance i change this to raycast or region3 or touched,
raycast module depends on the animation, touched is bad and idk how region3 works

did you ever fix this, I’m just wondering out of curiosity

I just reworked all the system but idk how to do a combat system properly

all of my combat systems have lag