local function s(s,k)if SETTINGS.Debug==true then for s,k in k do newInstance("\080\097\114\116",{Position=k,Anchored=true;CanCollide=false,Size=Vector3.one;Color=Color3.fromRGB(0,255,0);Transparency=.5;Parent=workspace.Debris})end end while#k>1 do local r=k k={}for z=1,#r-1,1 do local t=r[z]local w=r[z+1]table.insert(k,lerp(t,w,s))end end if SETTINGS.Debug==true then newInstance("\080\097\114\116",{Position=k[1],Anchored=true,CanCollide=false;Size=Vector3.one,Color=Color3.fromRGB(255,0,0),Transparency=.5;Parent=workspace.Debris})end return k[1]end return s

local function createCurve(t, points)
	if SETTINGS.Debug == true then
		for _, point in points do
			newInstance("Part", {
				Position = point,
				Anchored = true,
				CanCollide = false,
				Size = Vector3.one,
				Color = Color3.fromRGB(0,255,0),
				Transparency = .5,
				Parent = workspace.Debris
			})
		end
	end

	-- could use recursion, but lua doesn't have optimized tail calls. 
	while #points > 1 do
		local tempPoints = points
		points = {}

		for i = 1, #tempPoints - 1 do
			local p1 = tempPoints[i]
			local p2 = tempPoints[i + 1]

			table.insert(points, lerp(p1, p2, t))
		end
	end
	
	if SETTINGS.Debug == true then
		newInstance("Part", {
			Position = points[1],
			Anchored = true,
			CanCollide = false,
			Size = Vector3.one,
			Color = Color3.fromRGB(255,0,0),
			Transparency = .5,
			Parent = workspace.Debris
		})
	end
	
	-- points[1] will contain the correct position at time 't'
	return points[1]
end

return createCurve
