Bezier curve barrage effect help

hello my name is amaro and i have problems with bezier curve script, im making a barrage. the problem that is teleporting the part that is cloned with the original part. here is a example:

and here is the script where is the bezier curve:

Summary
local lowquality = true
game.ReplicatedStorage.BarrageEffect2.OnServerEvent:Connect(function(player)
	local effectfolder = workspace.Effects
	local char = player.Character
	local humanoidrootpart = char:WaitForChild("HumanoidRootPart")
	local stand = char:WaitForChild("Stand")
	local rot = stand:WaitForChild("StandHumanoidRootPart")
	local rightattachment = Instance.new("Attachment",char.HumanoidRootPart)
	rightattachment.CFrame = CFrame.new(6, 0, -2)
	rightattachment.Name = "rightt"
	local leftattachment = Instance.new("Attachment",char.HumanoidRootPart)
	leftattachment.CFrame = CFrame.new(-6, 0, -2)
	leftattachment.Name = "leftt"
	local endattachment = Instance.new("Attachment",char.HumanoidRootPart)
	endattachment.CFrame = CFrame.new(0, 0, -6.70)
	endattachment.Name = "endd"
	game.Debris:AddItem(rightattachment,1,2)
	game.Debris:AddItem(leftattachment,1,2)
	game.Debris:AddItem(endattachment,1,2)
	local start = humanoidrootpart.CFrame
	--right
	coroutine.resume(coroutine.create(function()
		local part = player.Character.Stand:WaitForChild("Stand Right Arm"):Clone()
		part.CFrame = start
		local p1 = rightattachment.WorldPosition +  Vector3.new(0,math.random(-3,3),0) + start.UpVector
		part.Parent = effectfolder
		part.CanCollide = false
		part.Anchored = true
		local p0 = start.Position + start.lookVector
		local p2 = endattachment.WorldPosition
		local tweendelay = wait()
		game.Debris:AddItem(part,1.1)
		for i,v in pairs(part:GetDescendants()) do
			if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("Texture") or v:IsA("Decal") then
				v.Transparency = 1
			end
		end	
		part.Transparency = 1
		delay(0.1, function()
			transparency(part)
		end)

		--Creating the effect 
		part.Name = "BarrageEffect" 
		part.Massless = true 
		part.CastShadow = false

		if lowquality == false then
			local holder = script.TrailHolder
			local at0 = holder.Attachment0:Clone() 
			local at1 = holder.Attachment1:Clone() 
			at0.Parent = part 
			at1.Parent = part
			local trail = holder.Trail:Clone() 
			trail.Attachment0 = at0 
			trail.Attachment1 = at1 
			trail.Parent = part
		end
		for i,v in pairs(part:GetDescendants()) do
			if v:IsA("ParticleEmitter") then
				v:Destroy()
			end
		end		

		for i = 0,0.07,.009  do
			local t = i/0.07
			local pos = quadraticBezier(t, p0, p1, p2)
			local direction = quadraticBezier(t + 0.010,p0,p1,p2)
			game.TweenService:Create(part, TweenInfo.new(tweendelay), {CFrame = CFrame.new(pos, direction) * CFrame.Angles(math.rad(90),0,0)}):Play()
			wait()
		end
	end))
	--left
	coroutine.resume(coroutine.create(function()
		local part = player.Character.Stand:WaitForChild("Stand Left Arm"):Clone()
		part.CFrame = start
		local p1 = leftattachment.WorldPosition +  Vector3.new(0,math.random(-3,3),0) + start.UpVector
		part.Parent = effectfolder
		part.CanCollide = false
		part.Anchored = true
		local p0 = start.Position + start.lookVector
		local p2 = endattachment.WorldPosition
		local tweendelay = wait()
		game.Debris:AddItem(part,1.1)
		for i,v in pairs(part:GetDescendants()) do
			if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("Texture") or v:IsA("Decal") then
				v.Transparency = 1
			end
		end	
		part.Transparency = 1
		delay(0.1, function()
			transparency(part)
		end)

		--Creating the effect 
		part.Name = "BarrageEffect" 
		part.Massless = true 
		part.CastShadow = false

		if lowquality == false then
			local holder = script.TrailHolder
			local at0 = holder.Attachment0:Clone() 
			local at1 = holder.Attachment1:Clone() 
			at0.Parent = part 
			at1.Parent = part
			local trail = holder.Trail:Clone() 
			trail.Attachment0 = at0 
			trail.Attachment1 = at1 
			trail.Parent = part
		end
		for i,v in pairs(part:GetDescendants()) do
			if v:IsA("ParticleEmitter") then
				v:Destroy()
			end
		end		

		for i = 0,0.07,.009  do
			local t = i/0.07
			local pos = quadraticBezier(t, p0, p1, p2)
			local direction = quadraticBezier(t + 0.010,p0,p1,p2)
			game.TweenService:Create(part, TweenInfo.new(tweendelay), {CFrame = CFrame.new(pos, direction) * CFrame.Angles(math.rad(90),0,0)}):Play()
			wait()
		end
	end))
end)
function lerp(a, b, c)
	return a + (b - a) * c
end

function quadraticBezier(t, p0, p1, p2)
	local l1 = lerp(p0, p1, t)
	local l2 = lerp(p1, p2, t)
	local quad = lerp(l1, l2, t)
	return quad
end

function transparency(disnuts)
	for i,v in pairs(disnuts:GetDescendants()) do
		if  v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("Texture") or v:IsA("Decal") then
			game.TweenService:Create(v,TweenInfo.new(0.13),{Transparency = 0}):Play()
		end
	end		
	game.TweenService:Create(disnuts, TweenInfo.new(0.13), {Transparency = 0}):Play()
	wait(0.05)
	for i,v in pairs(disnuts:GetDescendants()) do
		if  v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("Texture") or v:IsA("Decal") then
			game.TweenService:Create(v,TweenInfo.new(0.2),{Transparency = 1}):Play()
		end
	end		
	game.TweenService:Create(disnuts, TweenInfo.new(0.2), {Transparency = 1}):Play()
end

(note the red box that appears on the video is a hitbox, welded with the right arm or left arm)

function lerp(a, b, t)

	return a + (b - a) * t

end


function quadraticBezier(t, p0, p1, p2)

	local l1 = lerp(p0, p1, t)

	local l2 = lerp(p1, p2, t)

	local quad = lerp(l1, l2, t)

	return quad

end

p0 is the first position
p1 is the middle position
p2 is the end position
t is the time

1 Like

i kinda know T_T, but thanks for reply