I want to rotate a model along the Y axis (so it always stays vertical) to face another part. However, I don’t understand CFrames well enough to do this. Could someone help me here?
So far, I have this:
while true do
local cframe = CFrame.new(
Sentry:GetPrimaryPartCFrame().Position.X,
Sentry:GetPrimaryPartCFrame().Position.Y,
Sentry:GetPrimaryPartCFrame().Position.Z
) * CFrame.fromEulerAnglesXYZ(0,
CFrame.lookAt(Sentry.PlacePart.Position, TargetEnemy.Torso.Position).Rotation.UpVector.Y,
0
)
Sentry:SetPrimaryPartCFrame(cframe)
wait()
end
(also yes I do know that i shouldn’t put this in a while loop and should have a heartbeat connection but I’m just experimenting for now)
(I also know my code is terrible but again I’m just experimenting with this)
Anyone know how I should properly do the CFrame? Thanks.