Help with Bezier Curves

Currently im trying to figure out how to implement Bezier Curves into my rollercoaster but ive been running into some problems.

  1. I don’t know how to spread out my points in the curve evenly. The DevHub Article has a solution to this but I dont quite understand it. Bézier Curves | Roblox Creator Documentation

  2. Im also wondering how to change my blocks position from vector3 to cframe, so it would be possible to do upside down parts in my rollercoaster

My Script:


function lerp(p0, p1, t)
	return (1 - t) * p0 + t * p1
end


local function quadratic(p0, p1, p2, t)
	local L1 = lerp(p0, p1, t)
	local L2 = lerp(p1, p2, t)
	return lerp(L1, L2, t)
end



local function cubic(p0, p1, p2, p3, t)
	local Q1 = quadratic(p0, p1, p2, t)
	local Q2 = quadratic(p1, p2, p3, t)
	return lerp(Q1, Q2, t)
end



function travelCurve(p0, p1, p2, p3, cart)
   for t = 0, 1, 0.01 do 
		cart.Position = cubic(p0, p1, p2, p3, t) -- wondering how i can change .Position to CFrame
		local newpart = Instance.new("Part") -- test part to create points
		newpart.Anchored = true
		newpart.CanCollide = false
		newpart.Material = "Neon"
		newpart.BrickColor = BrickColor.White()
		newpart.Position = cubic(p0, p1, p2, p3, t)
		newpart.Size = Vector3.new(0.25, 0.25, 0.25)
		newpart.Parent = workspace
	wait()
	end
end

travelCurve(workspace.p0.Position, workspace.p1.Position, workspace.p2.Position, workspace.p3.Position, workspace.cart)

What I have Currently: https://i.gyazo.com/0a7c6d3e862e68004705b2c2a888e8bb.gif

Any help would be appreciated, i’m really desperate here.