Problem with weld or part

When creating the game I came across a problem that when I create a hitbox and weld it to the player, if the hitbox is bigger than the player’s size, the player is teleported back a bit.

I am using a modular script to create the hitbox:

local hitbox = {}

function hitbox.Create(size: Vector3, damage: number, hitboxTime: number, plr: Instance, C1: CFrame)
	
	hitbox.hitbox1 = Instance.new("Part", plr.Character)
	hitbox.hitbox1.CustomPhysicalProperties = PhysicalProperties.new(0.0001)
	hitbox.hitbox1.CanCollide = false
	hitbox.hitbox1.CFrame = plr.Character.HumanoidRootPart.CFrame
	hitbox.hitbox1.Name = "hitbox"
	hitbox.hitbox1.Size = size
	hitbox.hitbox1.Material = Enum.Material.ForceField
	hitbox.hitbox1.BrickColor = BrickColor.Red()
	hitbox.hitbox1:SetAttribute("damage", damage)
	
	hitbox.hitbox1:SetNetworkOwner(plr)
	task.wait()
	
	local weld = Instance.new("Weld", hitbox.hitbox1)
	weld.C1 = C1
	weld.Part0 = hitbox.hitbox1
	weld.Part1 = plr.Character.HumanoidRootPart
	
	game.Debris:AddItem(hitbox.hitbox1, hitboxTime)
	
end

return hitbox

Help me please, thank you in advance!

1

Probably try welding the HumanoidRootPart to the hitbox instead:

local weld = Instance.new("Weld", hitbox.hitbox1)
weld.C1 = C1
weld.Part0 = plr.Character.HumanoidRootPart 
weld.Part1 = hitbox.hitbox1

2

Try using WeldConstraint instead

This did not help, the second option is not suitable because you need to set the position at which the hitbox will be in front of the player

Not really, for my system, I first set the position Infront of the player then weld with WeldConstraint and consider enabling massless by the way.

local Weld = Instance.new("WeldConstraint")
Weld.Part0 = HumanoidRootPart
Weld.Part1 = Hitbox
Weld.Parent = Hitbox