How to make multiple parts line up horizontally relative to the player using mouse.hit.p

The title is pretty much self explantory i want to line up 4 different parts horizontally relative to the player using mouse.hit.p

current issue:

script:

local _settings = {
	Server = {
		distance_between_each = 20,
		defaultY = 200,
	},
}


for i = 1, amount, 1 do
    local manus = game.ServerStorage.manus:clone()

    local distance_between_mainpoint = _settings.Server.distance_between_each * (i - 1)
    if i == 1 then
        manus.CFrame =
            CFrame.new(
            mouseHit.p.X,
            mouseHit.p.Y + _settings.Server.defaultY,
            mouseHit.p.Z - _settings.Server.distance_between_each
        )
        firstmanus = manus
    else
        local firstmanuspos = firstmanus.Position
        warn("I: ", i, " dist: ", distance_between_mainpoint)
        manus.CFrame =
            CFrame.new(
            firstmanuspos.X,
            mouseHit.p.Y + _settings.Server.defaultY,
            (firstmanuspos.Z + distance_between_mainpoint)
        )
    end

    manus.Parent = playerFolder
    local tween1 =
        tweenService:Create(
        manus,
        TweenInfo.new(_settings.Server.Tweening.SizeSpeed, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out),
        {Size = _settings.Server.defaultSize}
    )
    tween1:Play()
end

Use cross product or CFrame.lookAt (uses cross product internally) to get the new horizontal relative to the player.

1 Like