Part Trail not working

I have figured out making the trail but I still need help since It does not connect properly.

you can do a loop here too just get the position of the red cube and the last position of the red cube and solve the orientation/rotate needed to it…

1 Like

Here is the script:

local function CFramePointRightSide(Pos1 ,Pos2)
	local directionToFace = (Pos1 - Pos2).unit
	local worldUp = Vector3.new(0,1,0)
	local zAxisFace = directionToFace:Cross(worldUp)
	local yAxisFace = directionToFace:Cross(zAxisFace)
	return CFrame.fromMatrix(Pos1, directionToFace, yAxisFace, -zAxisFace)
end

model = Instance.new("Folder")
model.Name = "Omega Points"
model.Parent = workspace
local mathHuge = math.huge

local function makePoints(oldPos, newPos)
	local Connect = Instance.new("Part", model)
	Connect.Anchored = true
	Connect.CanCollide = false
	Connect.Name = 	("Connect")
	Connect.Shape = Enum.PartType.Cylinder
	Connect.Material = Enum.Material.Neon
	Connect.Color = Color3.fromRGB(218, 0, 5)   
	local Distance = (oldPos - newPos).Magnitude
	Connect.Size = Vector3.new(Distance,0.3,0.3)					--	count_Parts[i + 1]			count_Parts[i + 1])
	Connect.CFrame =  CFramePointRightSide((oldPos + newPos)/2 , newPos) --  * CFrame.new(0,0,-Distance/2)
end

local SegmentVerts = {}


while wait(0.1) do
	part.Position = part.Position + Vector3.new(math.random(-4, 4), math.random(-3,3), math.random(0,0))
	for i = 1, 6 do
		wait(0.5)
		SegmentVerts[i] = part.Position
		if #SegmentVerts > 1 then
			if SegmentVerts[i + 1] ~= nil then
				--JoinVerts(SegmentVerts[i] , SegmentVerts[i + 1])
				--JoinVerts((SegmentVerts[i] + SegmentVerts[i + 1])/2, SegmentVerts[i + 1])
				makePoints(SegmentVerts[i], SegmentVerts[i + 1])
			end
		end
	end
end

I do not see a problem I have another script it works but it does not stay on it’s old position.

Figured everything out but it is too laggy how do I fix the lag? I will show the script later: