Hi! I'm currently having a model move along a path created by the Roblox PathFindingService. The model turns to face the point and then move towards the point. However, when I am having trouble on figuring out how I can speed up the model moving. If I increase the distance it moves, it messes up the turning and it also doesn't look smooth. Also, I know the way I am turning the model isn't really the best. So if you have anything else that would work better then please let me know! Here is the script.

	for i,v in ipairs(EditedPoints) do	
		if v ~= Points[1] and v ~= Points[#Points] then
			while (v - Plane.PrimaryPart.Position).magnitude > 3 do
				local EndRotation = math.deg(math.atan2(CFrame.new(Plane.PrimaryPart.Position, v).lookVector.x, CFrame.new(Plane.PrimaryPart.Position, v).lookVector.z))
				local Positive = math.deg(math.atan2((Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, 5, 0)).lookVector.x, (Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, 5, 0)).lookVector.z))
				local Negative = math.deg(math.atan2((Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, -5, 0)).lookVector.x, (Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, -5, 0)).lookVector.z))
				local Control = math.deg(math.atan2((Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, 0)).lookVector.x, (Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, 0)).lookVector.z))		
				
				if Control > EndRotation - 1 and Control < EndRotation + 1 then
					Plane:SetPrimaryPartCFrame(Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, 0))
				else
					if Control < EndRotation then
						Plane:SetPrimaryPartCFrame(Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, 0.005, 0))
					elseif Control > EndRotation then
						Plane:SetPrimaryPartCFrame(Plane:GetPrimaryPartCFrame() * CFrame.Angles(0, -0.005, 0))
					end					
				end
				
				Plane:SetPrimaryPartCFrame(Plane:GetPrimaryPartCFrame() + Plane:GetPrimaryPartCFrame().lookVector * 0.1)
				wait()
			end
		end
	end

Here is a link to Pastebin with the full code.

Link: https://pastebin.com/W6uw7r6j

2 comments

0

Have you tried to increase the numbers? Like instead of "5" you put like 8 or something else.

0

I have tried to increase the numbers. Although it doesn't make the model move as smoothly.