How to make a part trail system

I have made a part trail system and it is working but it keeps adding multiple models and all I want is one model but I can’t since it would not work as intended. I made multiple ways but they use one model instead of multiple.

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

Numbers = {
	Vector3.new(1, 0, 0),
	Vector3.new(1, 0.5, 0),
	Vector3.new(1, 1, 0),
	Vector3.new(0, 1, 0),
	Vector3.new(0, 1, 1),
	Vector3.new(0, 0, 1),
	Vector3.new(0.5, 0, 1)
}


function TransformModel(Objects, Center, NewCFrame, Recurse)
	local Objects = ((type(Objects) ~= "table" and {Objects}) or Objects)
	for i, v in pairs(Objects) do
		if v:IsA("BasePart") then
			v.CFrame = NewCFrame:toWorldSpace(Center:toObjectSpace(v.CFrame))
		end
		if Recurse then
			TransformModel(v:GetChildren(), Center, NewCFrame, true)
		end
	end
end

local function DoPoints(Length)
	local model3 = Instance.new("Model")
	model3.Name = "Omega Points Visualize"
	model3.Parent = workspace
	--Debris:AddItem(model3, 1)
	for i, v in pairs(Numbers) do
		local Part = Instance.new("Part")
		Part.Name = "Part"
		Part.Size = Vector3.new(Length,0.2, 0.2)
		Part.Parent = model3
		Part.Anchored = true
		Part.CanCollide = false
		Part.Color = Color3.fromRGB(218, 0, 5)   
		Part.Material = Enum.Material.Neon
		Part.Shape = Enum.PartType.Cylinder
		Part.CFrame = Part.CFrame * CFrame.new(Length,0,0)--omega_Lock.CFrame * CFrame.new(Length,0,0)--CFrame.new((Part.Size.X * (i - 1)), 0, 0)
		--Debris:AddItem(Part, 1)
	end
	Debris:AddItem(model3, 3.5)
	return model3
end

spawn(function()
	local LastPlace = nil
	local reached = false
while not reached do
	local CurrentPlace = makePart.Position

	if LastPlace then

		spawn(function()
			local Distance = (LastPlace - CurrentPlace).magnitude
			local Length = Distance + 0--3.5

			local PointsModel = DoPoints(Length)

			local PointsCFrame = CFramePointRightSide((LastPlace + (CurrentPlace - LastPlace).unit * (Distance / 2)), CurrentPlace)
			TransformModel(PointsModel, PointsModel:GetModelCFrame(), PointsCFrame, true)
			--Debris:AddItem(PointsModel, 10)
			LastPlace = CurrentPlace
		end)
	elseif not LastPlace then
		LastPlace = CurrentPlace
	end

	wait(Rate)
	end
end)
1 Like

Any help would be great since the multiple models makes it lag a lot than one model.

I might be understanding wrong, but you should just be able to use Trails.

I have used it but it is not what I want since it is flat and a part is 3D.

Figured it out. if you want to know how just message me about it.