How to make a bezier barrage effect

How to make a bezier barrage effect , i have a script here but idk how to use bezier , i tried so many way to make it work but i failed

local function BarrageVFX()
						if player:FindFirstChild("Data"):FindFirstChild("SkinValue").Value ~= nil then
							local value = player:FindFirstChild("Data"):FindFirstChild("SkinValue").Value
							local findskinmodel = game:GetService("ServerStorage").StandModel.TheWorld:FindFirstChild(value)
							if findskinmodel then
								
								local Stands = findskinmodel:Clone()
								
								local StartXR = math.random(-150,150)/100
								local StartXL = math.random(-150,150)/100 * -1
								local StartYR = math.random(-150,150)/100
								local StartYL = math.random(-150,150)/100
								local LeftArmModel = Instance.new("Model")
								LeftArmModel.Name = "LeftArm"
								LeftArmModel.Parent = game.Workspace
								
								local LLA = Stands:FindFirstChild("LeftLowerArm"):Clone()
								LLA.Parent = LeftArmModel
								local LUA = Stands:FindFirstChild("LeftUpperArm"):Clone()
								LUA.Parent = LeftArmModel
								local LH = Stands:FindFirstChild("LeftHand"):Clone()
								LH.Parent = LeftArmModel
								local weld1 = Instance.new("WeldConstraint")
								weld1.Part0 = LH
								weld1.Part1 = LLA
								weld1.Parent = LH 
								local weld2 = Instance.new("WeldConstraint")
								weld2.Part0 = LUA
								weld2.Part1 = LLA
								weld2.Parent = LUA
								
								LeftArmModel.PrimaryPart = LLA
								LeftArmModel.PrimaryPart.Anchored = true
								
								local attachment1 = IMPORTANTFOLDER.BarrageEffect.Attachment1:Clone()
								attachment1.Parent = LUA
								local attachment2 = IMPORTANTFOLDER.BarrageEffect.Attachment2:Clone()
								attachment2.Parent = LUA
								
								LeftArmModel.PrimaryPart.CFrame = CFrame.new(char.PrimaryPart.CFrame * CFrame.new(StartXL,StartYL,-1.5).p,char.PrimaryPart.CFrame * CFrame.new(StartXL * .4,StartYL * .4,-8).p) * CFrame.Angles(math.rad(90),0,0)

								local RightArmModel = Instance.new("Model")
								RightArmModel.Name = "LeftArm"
								RightArmModel.Parent = game.Workspace
		
								local RLA = Stands:FindFirstChild("RightLowerArm"):Clone()
								RLA.Parent = RightArmModel
								local RUA = Stands:FindFirstChild("RightUpperArm"):Clone()
								RUA.Parent = RightArmModel
								local RH = Stands:FindFirstChild("RightHand"):Clone()
								RH.Parent = RightArmModel
								local weld1 = Instance.new("WeldConstraint")
								weld1.Part0 = RH
								weld1.Part1 = RLA
								weld1.Parent = RH 
								local weld2 = Instance.new("WeldConstraint")
								weld2.Part0 = RUA
								weld2.Part1 = RLA
								weld2.Parent = RUA

								RightArmModel.PrimaryPart = LLA
								RightArmModel.PrimaryPart.Anchored = true
								
								local attachment1 = IMPORTANTFOLDER.BarrageEffect.Attachment1:Clone()
								attachment1.Parent = RUA
								local attachment2 = IMPORTANTFOLDER.BarrageEffect.Attachment2:Clone()
								attachment2.Parent = RUA

								RightArmModel.PrimaryPart.CFrame = CFrame.new(char.PrimaryPart.CFrame * CFrame.new(StartXR,StartYR,-1.5).p,char.PrimaryPart.CFrame * CFrame.new(StartXL * .4,StartYL * .4,-8).p) * CFrame.Angles(math.rad(90),0,0)
								
								local infronttween = TweenService:Create(RightArmModel.PrimaryPart,TweenInfo.new(.15),{CFrame = LeftArmModel.PrimaryPart.CFrame * CFrame.new(0,-3.5,math.random(-1.5,1.5))})
								
								infronttween:Play()
								
								infronttween.Completed:Connect(function()
									for i ,  v  in pairs(LeftArmModel:GetDescendants()) do
										if v:IsA("Texture") or v:IsA("BasePart") or v:IsA("Decal") then
											v.Transparency = 0
											local invistween = TweenService:Create(v,TweenInfo.new(.5),{Transparency = 1})
											invistween:Play()
											invistween.Completed:Connect(function()
												LeftArmModel:Destroy()
											end)
										end
									end
								end)
								
								local infronttweens = TweenService:Create(RightArmModel.PrimaryPart,TweenInfo.new(.15),{CFrame = RightArmModel.PrimaryPart.CFrame * CFrame.new(0,-3.5,math.random(-1.5,1.5))})

								infronttweens:Play()

								infronttweens.Completed:Connect(function()
									for i ,  v  in pairs(RightArmModel:GetDescendants()) do
										if v:IsA("Texture") or v:IsA("BasePart") or v:IsA("Decal") then
											v.Transparency = 0
											local invistween = TweenService:Create(v,TweenInfo.new(.5),{Transparency = 1})
											invistween:Play()
											invistween.Completed:Connect(function()
												RightArmModel:Destroy()
											end)
										end
									end
								end)
							end
						end
					end
1 Like

Can you elaborate a bit further on what you’re trying to achieve?

Also Roblox has an article on Bezier Curves which could prove useful to you if you check it out here:

i read it and understand it but i cant make it bezier tween.

You can’t which is why you implement a tweening system yourself using cframes.

script i sent above is a simple barrage effect i made and i trying to make it bezier

If you can’t use tweening try using a loop. An example would be to do something like this:

function QuadraticBezier(t,p0,p1,p2)
	return (1-t)^2*p0+2*(1-t)*t*p1+t^2*p2
end

for t = 0, 1, 0.025 do
     local increment = QuadraticBezier(t, START, MIDDLE, GOAL)
     --you can then set the position of whatever to the increment variable stated above
     task.wait()
end

If you have any questions feel free to ask!

1 Like

i saw the script and the start i need to add attachment ?

i tried you script and made this , any improvement that i can change in my script?

function CleanPart(part)
	for _,i in pairs(part:GetDescendants()) do
		if i:IsA("Motor6D") or i:IsA("Weld") then
			i:Destroy()
		end
	end
end

while true do
	wait(.24)
	spawn(function()
		local Chand = Instance.new("Model")
		Chand.Parent = workspace
		Chand.Name = "Handssssss"
		local Arm
		local Lower
		local Hand
		local p1
		local LeftOrRight = math.random(1,2)
		local p0 = script.Parent.HumanoidRootPart.Position
		if LeftOrRight == 1 then
			Arm = script.Parent.LeftUpperArm:Clone()
			CleanPart(Arm)
			Arm.Parent = Chand
			Lower = script.Parent.LeftLowerArm:Clone()
			CleanPart(Lower)
			Lower.Parent = Chand
			Hand = script.Parent.LeftHand:Clone()
			CleanPart(Hand)
			Hand.Parent = Chand
			Arm.Name = "Arm"
			Lower.Name = "Lower"
			Hand.Name = "Hand"

			p1 = script.Parent.HumanoidRootPart.Left.WorldPosition + Vector3.new(0,math.random(-3,3),0)
		else
			Arm = script.Parent.RightUpperArm:Clone()
			CleanPart(Arm)
			Arm.Parent = Chand
			Lower = script.Parent.RightLowerArm:Clone()
			CleanPart(Lower)
			Lower.Parent = Chand
			Hand = script.Parent.RightHand:Clone()
			CleanPart(Hand)
			Hand.Parent = Chand
			Arm.Name = "Arm"
			Lower.Name = "Lower"
			Hand.Name = "Hand"

			p1 = script.Parent.HumanoidRootPart.Right.WorldPosition + Vector3.new(0,math.random(-3,3),0)
		end
		local Weld = Instance.new("WeldConstraint")
		Weld.Part0 = Hand
		Weld.Part1 = Lower
		Weld.Parent = Hand
		local wedl = Instance.new("WeldConstraint")
		wedl.Part0 = Arm
		wedl.Part1 = Lower
		wedl.Parent = Arm
		Chand.PrimaryPart = Lower
		Chand.PrimaryPart.Anchored = true
		Chand.PrimaryPart.CanCollide = false
		local p2 = script.Parent.HumanoidRootPart.End.WorldPosition
		local TweenDelay = wait()
		game.Debris:AddItem(Chand,1)
		game.TweenService:Create(Chand.PrimaryPart,TweenInfo.new(1),{Transparency = 1}):Play()
		game.TweenService:Create(Chand.Arm,TweenInfo.new(1),{Transparency = 1}):Play()
		game.TweenService:Create(Chand.Hand,TweenInfo.new(1),{Transparency = 1}):Play()
		
		for i = 1, 5 do
			local t = i/5
			local pos = quadBezier(t, p0, p1, p2)
			local Direction = quadBezier(t + 0.005, p0,p1, p2)
			--hand.CFrame = CFrame.new(pos,Direction)
			game.TweenService:Create(Chand.PrimaryPart,TweenInfo.new(TweenDelay),{CFrame = CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)}):Play()
			--game.TweenService:Create(Chand.Hand,TweenInfo.new(TweenDelay),{CFrame = CFrame.new(pos * 1, Direction) * CFrame.Angles(math.rad(90),0,0)}):Play()
			--game.TweenService:Create(Chand.Arm,TweenInfo.new(TweenDelay),{CFrame = CFrame.new(pos * 1, Direction) * CFrame.Angles(math.rad(90),0,0)}):Play()
			wait()		
		end
	end)	
end

https://gyazo.com/85e17287673611cd238bee35bae7b80e