Sword Hitbox Help

How would i go about making a sword hitbox.
I have a model attached to player via motor6d, but what would be the beast way to make a hitbox system.
Ive tried :Touched, yet its not reliant, :GetPartsInPart glitches and every once in a while one shots. Can someone point me into a direction or demonstrate some code.

I’ll be honest Im not the best with hitboxes but what’s so glitchy about the touched event?

Its apparently semi ping reliant, and just isnt the best for registering hitboxes

Don’t use .Touched it is inconsistency because it relies on ping and Roblox physic

Instead use :GetPartBoundsInBox() or :GetPartInPart()
in this case I’ll use :GetPartBoundsInBox()

Note that you don’t really need to create a physical part for a hitbox for it to work I just want thing easy

function CreateHitbox()

	local Hitbox = Instance.new("Part") -- from this
	if VisualizeHitbox then
		Hitbox.Transparency = .5
	else
		Hitbox.Transparency = 1
	end
	Hitbox.CanCollide = false
	Hitbox.CanTouch = true
	Hitbox.CanQuery = false
	Hitbox.Anchored = true
	Hitbox.Size = Vector3.new(5,5,5)
	Hitbox.CFrame = Dummy.PrimaryPart.CFrame * CFrame.new(0,0,-2)
	Hitbox.Parent = Dummy -- to this isn't nesessary I just make it easy to control the size of the actual hitbox and also visualize it

	local Enemy = workspace:GetPartBoundsInBox(Hitbox.CFrame, Hitbox.Size) -- get everypart inside a box (In this case the hitbox we just create, I told you it will be easier this way)
	for i, v in pairs(Enemy) do -- run a loop through the part that is inside the box
		local Char = v.Parent
		if not Char or Char == Dummy then continue end -- exclude itself
		if table.find(Hit, Char) then continue end -- check if the character is already been hit
		local Hum = Char:FindFirstChild("Humanoid")
		if not Hum then continue end -- check if it has humanoid
		if Hum.Health <= 0 then continue end -- don't hit the dead thing
		local Player = game.Players:GetPlayerFromCharacter(Char)
		if not Player then continue end -- this is unnesessary I just don't want the npc to hit other thing than player

		-- deal damage
		
		table.insert(Hit, Char) -- insert the character that has been hit into the table for check later
	end
	Debris:AddItem(Hitbox, 0.3) -- delete the hitbox
end

then after the animation end use table.clear(Hit) to reset the list so it can be hit later

Unless you want players to see a hitbox I suggest using raycasts.

Simply fire a raycast to every player in the game and see if a player is in the range. GetPartBoundsInBox can also be used like @Nami11255 demonstrated however I would prefer using raycasts due to its simplicity. The choice is ultimately yours.