How do I create a CFframe using a new Position but a already made Orientation?

I have been spending the last 3-4 hours trying to find a way to duplicate two daggers and tween them to where they hit without needing to change the rotation. I think the better way of doing this is to have them tween to where they hit with their orientation an inverse look vector(or a look away) at playerTorso but I am not sure how to inverse a look vector. I actually don’t know what a look vector is, I was only using the CFrame.new(vector3 pos, vector3 lookAt). My code is:

local mag = (MousePosition - plr.Character.HumanoidRootPart.Position).magnitude

local TI = TweenInfo.new(mag * script.Parent.Config.ThrowSpeed.Value,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
local CFrame_ = CFrame.new(MousePosition, plr.Character.HumanoidRootPart.Position)

local a = CFrame.new(MousePosition) * CFrame.Angles(script.Parent.LeftDagger.Orientation.X,script.Parent.LeftDagger.Orientation.Y,script.Parent.LeftDagger.Orientation.Z)

local LeftClone = game.ServerStorage.WeaponStorage.Daggers.Dagger:Clone()
local RightClone = game.ServerStorage.WeaponStorage.Daggers.Dagger:Clone()

LeftClone.CFrame = script.Parent.LeftDagger.CFrame
RightClone.CFrame = script.Parent.RightDagger.CFrame
LeftClone.Parent = workspace
RightClone.Parent = workspace

local LDaggerTween = TS:Create(LeftClone,TI,{CFrame = a })
local RDaggerTween = TS:Create(RightClone,TI,{CFrame = a })

LDaggerTween:Play()
RDaggerTween:Play()
2 Likes

A CFrame - the CFrame’s Position leaves you with the CFrame.Angles component.

local cframe = CFrame.new(Vector3.new(0, 0, 0), Vector3.new(1, 0, 0))
local Orientation = cframe - cframe.Position

To add a new position while maintaining this orientation all you would need to do is add the position to this orientation.

local a = Vector3.new(100, 5, 100)
local newCFrame = Orientation + a

And now you have a CFrame with the same orientation, but a new position.

7 Likes

What if I wanted to to rotate a CFrame -90 on the X axis? I haven’t quite got a hand on this whole CFrame thing.

Then you can multiply the CFrame by CFrame.Angles(math.rad(90),0,0). You have to use math.rad as that function takes it in radians (math.rad converts degrees into radians).

Also, the original post has been answered. You should award a solution to Deleavs’ reply.

2 Likes