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!