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

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

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)

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 ="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 =, 0.25, 0.25)
		newpart.Parent = workspace

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

What I have Currently:

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