Hello! Im making a fighting game and i am trying to make the hitboxes work. Right now, the hitbox spawns and deals damage like it should be, but it’s position varies everytime the player turns.
Any reason why this is happening?
local function newHitBox(character, size, offset, damage, linger)
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp == nil then
return
end
local weld = Instance.new('WeldConstraint', hrp)
local hitbox = Instance.new('Part')
weld.Part0 = hrp
weld.Part1 = hitbox
hitbox.CanCollide = false
hitbox.CanQuery = false
hitbox.Massless = true
hitbox.Size = size
hitbox.CFrame = hrp.CFrame + Vector3.new(offset.X, offset.Y, offset.Z)
hitbox.Parent = character