Struggling to make specific trail effect

Hello developers. Recently I have been trying to create some cool things I’ve seen so I can become a better developer. I have tried remaking this puzzle from an old game and have made most of it but I’m stuck on this trail that gets bigger as you move the part forward and it stays behind the part,
but it also leaves its previous movement behind and vice versa when dragging it back. I have tried stuff like setting the parts Size.Z to the magnitude between the parts and many other things but have had no luck. Any help would be appreciated. Below is a video of what I want to achieve and what code I have so far.

local Mouse = game.Players.LocalPlayer:GetMouse ()
local holding = false
local target
Mouse.Button1Down:Connect(function()
	if Mouse.target ~= nil and Mouse.target:IsA("Part") then
		holding = true
		target = Mouse.target
		Mouse.TargetFilter = target
	end
end)

Mouse.Move:Connect(function()
	if not down then return end
	if target.Name ~= "Green" then return end
	local mt = Mouse.target
	if mt:IsA("Part") then
	target.Position = mt.Position + Vector3.new(0,.5,0)	
        --CREATE TRAIL
       				
	end	
end)

Mouse.Button1Up:Connect(function()
 	holding = false
	target = nil
	pcall(function() Mouse.TargetFilter = nil  end)
end)

Try to maintain a table, containing all the parts in the current path.

Use that table to draw the path using a for loop.

There are more details, but you said you wanted to learn so have at it :slight_smile: