Reversing bezier curves

I’ve read this article about bezier curves and I was able to create this


BUT I don’t know how would I get this position from the marker

image

Here’s my code:

-- update() function calculates the point using t value

game:GetService("RunService").RenderStepped:Connect(function(dl)
	if not updatedSegments then
		cache:ClearAllChildren()
		local lastPoint = p1.Position
		for i = 1, segments do
			t = i / segments
			update()
			local line = Instance.new("Frame", cache)
			line.Name = tostring(i)
			line.BorderSizePixel = 0
			line.Size = UDim2.fromOffset(0, 2)
			drawPath(line, lastPoint, curvePoint.Position)
			lastPoint = curvePoint.Position
		end
		updatedSegments = true
	else
		local lastPoint = p1.Position
		for i = 1, segments do
			t = i / segments
			update()
			local line = cache[tostring(i)]
			drawPath(line, lastPoint, curvePoint.Position)
			lastPoint = curvePoint.Position
		end
	end

	drawPath(PointLines[1], p1.Position, p2.Position)
	drawPath(PointLines[2], p4.Position, p3.Position)

	if dragging then
		local x, y = mouse.X, mouse.Y
		x = math.max(dragging.Parent.AbsolutePosition.X, math.min(dragging.Parent.AbsolutePosition.X + dragging.Parent.AbsoluteSize.X, x)) - dragging.Parent.AbsolutePosition.X
		y = math.max(dragging.Parent.AbsolutePosition.Y, math.min(dragging.Parent.AbsolutePosition.Y + dragging.Parent.AbsoluteSize.Y, y)) - dragging.Parent.AbsolutePosition.Y
		if dragging.Parent.Size.Y.Offset == 1 then
			y = 0
		end
		dragging.Position = UDim2.fromScale(x / dragging.Parent.AbsoluteSize.X, y / dragging.Parent.AbsoluteSize.Y)
	end
	
	
	local reversedCurve = timelineMarker.Position.X.Scale
	
	-- Reverse the X value??
	
	t = reversedCurve
	update()
	tlmVer.Position = UDim2.new(t, -1, 0, 0)
	tlmHor.Position = UDim2.new(0, 0, curvePoint.Position.Y.Scale, -1)
end)

Use the marker’s X scale position as the alpha t, which you will use to calculate the point on the bezier curve with the same control points you have

That doesn’t work, because the X value isn’t the same as the t value, the curved line is longer than the straight lineimage

Not much time right now: factor and use the cubic formula, there will be 0, 1, 2, or 3 solutions