How do I set Orientation and Position to the CFrame at once?

I trying to make the car look at something and move it at the same, how can I do that? Those are my current methods that change orientation and position.

local direction = tweenservice:Create(car, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { CFrame = CFrame.new(car.Position, p1.WorldPosition) })
local move = tweenservice:Create(car, TweenInfo.new(speed, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Position = p1.WorldPosition })

I am terrible at cframes.

CFrames encompass both position and orientation, so just do CFrame = car.CFrame ? Or CFrame = p1.CFrame, if p1 is an attachment.

However p1 doesn’t have proper orientation. So the car stays in the incorrect orientation. That’s why I am trying to make the car look at the p1 position.

try CFrame = CFrame.new(p1.WorldPosition) * CFrame.Angles(math.rad(p1.WorldOrientation.X),math.rad(p1.WorldOrientation.Y),math.rad(p1.WorldOrientation.Z))

it sets the position of the car to the attachment. Since the attachment doesn’t have a proper orientation it creates a new orientation for the car based on the attachment’s WorldOrientation in radians.

1 Like