Alright, I’ll give you a simple demonstration. Lets say you want the a part to move from PointA to pointB. You would do it like this (I used TweenService to move the part in this example):
local TweenService = game:GetService("TweenService")
local Part = workspace.Part
local PointA = Vector3.new(0, 0, 0)
local PointB = Vector3.new(0, 50, 0)
local Dist = (PointA - PointB).magnitude -- The distance between PointA and PointB
local TotalPoints = 10 -- The number of of times you want the projectile to "zig-zag"
local MaxOffset = 10 -- The max offset of each point in studs
local Duration = 0.25 -- The duration of the interpolation between each point
local Info = TweenInfo.new(Duration, Enum.EasingStyle.Linear)
-- Set the parts initial cframe to be at PointA
Part.CFrame = CFrame.new(PointA)
for i = 1, TotalPoints do
-- First get the point on the linear path
local pointCF = CFrame.new(PointA, PointB) * CFrame.new(0, 0, -Dist * (i / (TotalPoints + 1)))
-- Calculate the offset of the point from the path
local offset = CFrame.new(math.random() * MaxOffset, math.random() * MaxOffset, 0)
-- Apply the offset to the point cframe
local finalPointCF = pointCF * offset
-- Move the part towards the final point cframe
local tween = TweenService:Create(Part, Info, {CFrame = finalPointCF})
tween:Play()
wait(Duration)
end
-- And finally, move the part towards the ending position
local tween = TweenService:Create(Part, Info, {CFrame = CFrame.new(PointB)})
tween:Play()
And here’s how it should turn out:
