LookAt rotating part with wrong side

The arrow is supposed to be rotated from front of it to the Mouse Hit Position, but CFrame.lookat() rotates it according to right/left side of Arrow and not front

image

Script:

local newArrow = SS.UsedForScripts.Arrow:Clone()
newArrow.Parent = workspace
newArrow.PrimaryPart.CFrame = Handle.CFrame
local Distance = (MousePos.p-Handle.Position).Magnitude
local lookAt = CFrame.lookAt(newArrow.PrimaryPart.Position,MousePos.p)
local CF = CFrame.new(MousePos.p) * CFrame.Angles(lookAt:ToOrientation())
local newArrowAnim = TS:Create(newArrow.PrimaryPart,TweenInfo.new(1,Enum.EasingStyle.Linear),{CFrame=CF}); newArrowAnim:Play()
1 Like

Rotate your final rotation by CFrame.fromAxisAngle(Vector3.yAxis, math.pi/2)
I am guessing which axis, it will either be xAxis or yAxis, and either +/- pi/2. So you’ll need up to two guesses.

2 Likes

The result:

local CF = (CFrame.new(MousePos.p) * CFrame.Angles(lookAt:ToOrientation())) * CFrame.fromAxisAngle(Vector3.yAxis, math.pi/-2)

Thank you ;d

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.