Make part face the next waypoint

This is what I have not sure how to make it all work together the part moves perfectly toward everyway point but I just need it to face the one it is heading towards… :thinking:… also once the part makes it all the way around it stops for the amount of (Time) is, I’d like to just continue without any stopping. Time also controls the speed so is there a way to separate the speed of the part using this TweenInfo and the time it moves around to each waypoint?

local balloon = script.Parent

local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	
	1, -- Time
	Enum.EasingStyle.Linear, -- Easinmg Style
	Enum.EasingDirection.Out, -- Easing Direction
	0, -- Repeat Count
	false, -- Reverse
	0 -- Delay Time
)

local CFrames = {
	workspace:WaitForChild("Waypoints"),
	workspace["Waypoints"]:WaitForChild("waypoint 2").CFrame,
	workspace["Waypoints"]:WaitForChild("waypoint 3").CFrame,
	workspace["Waypoints"]:WaitForChild("waypoint 4").CFrame,
	workspace["Waypoints"]:WaitForChild("waypoint 1").CFrame,
}

local i = 0
while true do
	i = (i-1)%#CFrames + 2
	local nextCFrame = CFrames[i] -- CFrame you want it to set
	local tween = TweenService:Create(balloon, tweenInfo, {
		["CFrame"] = nextCFrame 
	})
	tween:Play()
	tween.Completed:Wait() -- wait for it to complete

end


local blimp = game.Workspace.GameMap.Blimp
local position = blimp.CFrame.Position

local startPosition = Vector3.new(position)
local targetPosition = CFrames

blimp.CFrame = CFrame.new(startPosition, targetPosition)

local rotatedCFrame = CFrame.Angles(math.rad(-90), 0, 0)
blimp.CFrame = blimp.CFrame:ToWorldSpace(rotatedCFrame)
2 Likes

You can use CFrame.lookat() for this:

local part = --the part you want to look towards the other part

local part2 = --the part that will be looked at

part.CFrame = CFrame.lookat(Part.Position, Part2.Position)
1 Like

the script at the bottom somehow has to be added into the while loop for it to all work smoothly, if I put the code below, the while loop never brakes so, it never reaches that part of the script, or if I put it above the while loop never runs. So, it has to be implemented into the while loop somehow, I just don’t know how to do that.