How do I make model rotate to the direction of what it move?


Here is what happens.

My code:

if i > 2 then

			local targetPosition = Vector3.new(waypoints.Position.X, 0, waypoints.Position.Z)  -- Access the Position property
			local StartPoint = dummy.WorldPivot.Position

			for i = 0, 1, 1/20 do

				dummy:PivotTo(CFrame.new(StartPoint:Lerp(targetPosition, i)))

				RS.Heartbeat:Wait()

			end

I’m happy to any help!

1 Like

Try using CFrame.lookAt(start,look at)

The reason this is happening is because you are setting the CFrame of the dummy to a cframe without rotation. To fix this, all you have to do is replace this line:

dummy:PivotTo(CFrame.new(StartPoint:Lerp(targetPosition, i)))

with this:

dummy:PivotTo(CFrame.lookAt(StartPoint:Lerp(targetPosition, i), targetPosition))

thank you very much for your help!

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