Quadratic equation displays a line that is way too large

here is my code, I am only giving this function the values of
MaxDistance = 200
MaxHeight = 100
for now.

local function DisplayCurve(MaxDistance, MaxHeight)
	for i,v in pairs(Curves:GetChildren()) do
		v:Destroy()
	end

	local x = 0
	local m = 0.01
	local y = m * (x^2) + MaxHeight

	local BallPos = GetPlayerBall().Position

	local first = CurvePoint:Clone()
	first.Parent = workspace.SwingCurves
	first.Position = BallPos

	local PreviousPoint = first.Position

	repeat
		x -= 1
		y = m * (x^2) + MaxHeight

		local Point = CurvePoint:Clone()
		Point.Parent = Curves
		Point.Position = PreviousPoint + Vector3.new(0,y,x)

		PreviousPoint = Point.Position
		print(y)
		wait(0.1)
	until #Curves:GetChildren() == 100
end

SwingFullTrack:GetMarkerReachedSignal("BallContact"):Connect(function(paramString)
	
	DisplayCurve(200,100)
	
end)

and it only creates 100 parts, but I am planning to change that later.

the curve is supposed to reach 100 at the top, and come back down to 0 at x=200, but right now y just increases into the thousands.
y=2600 when x = 500 (i removed the until statement to let it get that high)

here is the graph I am trying to create:


and I get this in game:

is there any way to stop it at 100 and return back to zero like in the desmos graph?

1 Like

You forgot the negative

which negative? i need more characters and Idk what to write

Your equation should be local y = -(m * (x^2)) + MaxHeight

it still has the same curve that’s way too big, I think it’s something to do with the math being wrong or the way I wrote the math being wrong

your also decreasing the X instead of increasing it

Basically you have the curve flipped

yeah, I do that because if I increase x, the curve travels the opposite way, so I just decrease it instead.

Also check the amount of parts your creating, your only creating 100 when you should be creating 200.

this is sort of my problem, I tried creating 200 parts but y just increases further.

Maybe try dividing y to decrease the height?

y = (m * (x^2) + MaxHeight) / 2 -- or something like that, idk

Try using Point.Position = Vector3.new(0,y,x) instead? Adding the PreviousPoint is why the curve keeps multiplying, but after running it I got a really weird curve so I assume I did something wrong