# Problem when doing Barrage in Arc using Bézier

Hello, I found this code for making a barrage in arc effect using Bézier curves:

``````local function TweenArm(Arm,pivotCFrame)
local ArmStartCf = Arm.CFrame
local TimePassed = 0

local rnd = Random.new()
local rndCF = CFrame.new(rnd:NextInteger(-4,4),rnd:NextNumber(-5,5),rnd:NextNumber(-4,4))

local Speed = 2
local Duration = (ArmStartCf.p - pivotCFrame.Position).Magnitude / Speed
local tweenDelay = 0.1

TimePassed = 0
while TimePassed < Duration do
local TimeRunning = TimePassed / Duration
local MiddlePoint = (ArmStartCf * rndCF).p

if TimePassed == 0 then
Arm.CFrame = CFrame.new(pointAtTimePassed,Bezier_Module:QuadraticBezier(TimeRunning+.01,ArmStartCf.p,(ArmStartCf * rndCF).p, pivotCFrame.p))
elseif TimePassed == Speed then
local tween = TweenS:Create(Arm,TweenInfo.new(.4),{Transparency = 0}):Play()
end

TimePassed += Speed
local tween = TweenS:Create(Arm,TweenInfo.new(tweenDelay),{CFrame = CFrame.new(pointAtTimePassed,lookAt)})
tween:Play()
end
end)
``````

My problem is, it doesn’t look as I expected it to, the arms are supposed to move horizontally like this:

Instead it ends moving this way, and I don’t know how to fix that.

I’ve tried a loop setting the orientation and the CFrame.Angles, but Orientation doesn’t give a good result and CFrame.Angles doesn’t work.

The Blocks are just a clone of the stand arms:

``````		local LeftArm = Stand:WaitForChild("Left Arm"):Clone()
LeftArm:ClearAllChildren()
LeftArm.CanCollide = false
LeftArm.Anchored = true
LeftArm.Parent = BarrageEffectsFolder
LeftArm.Transparency = 1

local RightArm = Stand:WaitForChild("Right Arm"):Clone()
RightArm:ClearAllChildren()
RightArm.CanCollide = false
RightArm.Anchored = true
RightArm.Parent = BarrageEffectsFolder
RightArm.Transparency = 1
``````

How could I fix this issue?

1 Like

I’d guess it’s because the direction of the length of the arm isn’t the Z axis as it should have been, but the Y axis. Change the target CFrame to

``````{CFrame = CFrame.new(pointAtTimePassed,lookAt) * CFrame.angles(0, 0, math.deg(90)}
``````

… or some other variation, I’m not sure which axis you need to rotate on to get it right. Just try rotating on different axes, or in the opposite direction (-90 instead of 90).

2 Likes

Can you drop modules? i want to learn bezier with arm skill