Issue with Bezier curve on projectiles

Hello! I’m working on a project and have been trying to use Bezier curves to create curved projectiles, it’s working mostly fine by changing the projectile’s rotation and then adjusting its velocity based on that, however there seems to be a problem somewhere in the formula as my projectiles have been shooting out weirdly when facing a specific direction.

The projectiles are supposed to spread out and then converge on the central point as it happens on three of the four directions, however 2 of the projectiles decide to wrap around the player before going towards its destination when aiming at a specific direction.

I’ve tried looking for the mistake and tweaking the formula a bit but have been unsuccessful in finding the issue, i would appreciate if anyone could point out my mistake.

Below is the code responsible for shooting out these curved bullets, the AngleX, AngleY, AngleZ and baseSpeed variables are all passed down as function parameters.

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

	bullet.CFrame = CFrame.new((Humrp.CFrame * CFrame.new(0, 0, 0)).p,direction):ToWorldSpace(CFrame.Angles(math.rad(x), math.rad(y), math.rad(z)))
	local Vel = Instance.new("BodyVelocity", bullet)
	Vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	Vel.Velocity = (bullet.CFrame.LookVector * baseSpeed) + Humrp.Velocity

	local angle = coroutine.wrap(function()
		local start = bullet.Orientation
		local rx, ry, rz = CFrame.new((Humrp.CFrame * CFrame.new(0, 0, 0)).p,direction):ToWorldSpace(CFrame.Angles(math.rad(angleX), math.rad(angleY), math.rad(angleZ))):ToOrientation()
		local goal = Vector3.new(math.deg(rx), math.deg(ry), math.deg(rz))
		local curvePoint = start:Lerp(goal, 0.5)
		
		for t = 0,1,0.01 do
			wait()
			local TargetPosition = QuadraticBezier(t , start, curvePoint, goal);
			bullet.Orientation = TargetPosition
			Vel.Velocity = (bullet.CFrame.LookVector * baseSpeed) + Humrp.Velocity
		end
	end)
	
	angle()