How do I make a part face, then move to another part

Hi, everyone.
If I have two points, how can I make a “bolt” spawn at point1, face point2, then move towards point2?
If you don’t understand what I am trying to say, I made a gif:
https://gyazo.com/c331bbf323cd67bfbef7c9355dea1830
(blue brick being point1, yellow brick being point2, and red brick being the “bolt”)

This can be easily done by the CFrame.new() constructor, CFrame.new() has another argument which is the way the CFrame should be facing:

Bolt.CFrame = CFrame.new(Bolt.Position, Point2.Position)

For moving, I’d say TweenService. Create a new tween where the desired CFrame is Point2:

local ts = game:GetService("TweenService")
local tween = ts:Create(Bolt, TweenInfo.new(1), {CFrame = Point2.Position})
tween:Play()

You can read more about TweenService here:

4 Likes

I think this is working. The issue is, it is moving so fast that it basically teleports. How can I slow down the movement?

Edit: Nevermind, I just change the first parameter of the TweenInfo.

Actually I just realized I have a problem. This was meant to be for a gun, and I can’t have the bolt travel at a set time.

Edit: Nevermind, I can just do this:

local speed = (p1 - p2).magnitude / 50

local ts = game:GetService("TweenService")
local tween = ts:Create(bolt, TweenInfo.new(speed, Enum.EasingStyle.Linear), {Position = workspace.pos2.Position})
tween:Play()