This Trajectory Script Isn't Doing What I Want It To

Hello

I am working on a paint gun for my upcoming game, I adjusted a script I found on the Dev Forum that shows the trajectory of the paint that will come out of the gun. Here is the function that creates the trajectory

local function Beam_Func()
	local part
	if player.Character then
		local upperTorso = player.Character:FindFirstChild("UpperTorso")
		if upperTorso then
			part = upperTorso
		end
	end
	local mouse = game.Players.LocalPlayer:GetMouse()
	local disp = (mouse.Hit.p - part.Position)
	local mag = math.min(script.Parent.radius.Value, disp.Magnitude)
	local pos = disp.Unit * mag + part.Position

	local X0 = startPoint.CFrame.Position
	local V0 = (pos - X0 - 0.5*Gravity*T*T)/T

	local Curve0, Curve1, CF1, CF2 = BeamProjectile_Func(V0, X0, T)
	Beam.CurveSize0 = Curve0
    Beam.CurveSize1 = Curve1

	Attach0.CFrame = Attach0.Parent.CFrame:inverse() * CF1
	Attach1.CFrame = Attach1.Parent.CFrame:inverse() * CF2
end

Here is what I’m trying to achieve, I want the trajectory to end exactly where the mouse is, but the problem is that the trajectory ends on the max radius of 25 on the pathway to where the mouse hits. The problem is that this can create some weird trajectories

Here’s a visual of what I’m trying to do.

WeirdTrajectory

If I need to elaborate on anything else, please let me know. Thanks.