CFrame.LookAt not working

So as the title suggets CFrame.lookat isnt working that well, here is an image

the selected is AirdropPoint1, and quite obvious the plane isnt facing at the part
image


Here is the Rootpart which im doing the cframe.lookat with. Its facing front so the plane should be facing to the part but its not and idk why.
Here is the code:

CargoClone.Root.Orientation = Vector3.new(0, CFrame.lookAt(CargoClone.Root.Position, AirDropPoints.AirdropPoint1.Position).Y,0)

Changing the orientation of a part inside a model directly will not apply to the rest of the model. You should be using Model:PivotTo() which takes a CFrame to reposition the model. Alternatively if the part inside a model is welded to the rest of the model then changing the CFrame of that part will also apply to all welded parts (assuming you are using a WeldConstraint and not a Weld).

Example:

plane:PivotTo(
    CFrame.lookAt(plane:GetPivot().Position, targetPosition)
)
2 Likes

do i do cargo:pivotto(AirDropPoints.AirdropPoint1.CFrame)?

I’m not sure exactly what you are trying to do but I’ve updated my first answer to include an example of using it

It worked, just a question should i do

plane:PivotTo(
    CFrame.lookAt(plane:GetPivot().Position, targetPosition).Y 
)

for it to only rotate on Y axis?

I’m not sure what that does, I wasn’t even aware that CFrame.Y was a thing but what I would do is make sure that the Y component of the two vectors you pass to CFrame.lookAt() are equal so there is no rotation along those axes. You can replace replace targetPosition with Vector3.new(targetPosition.X, planePosition.Y, targetPosition.Z)

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