Adding Nodes and Attachments to parts

Hey Devforum,

I need to add LastNode and NextNode to “Follow” parts. (Red parts in middle) Also, I need to add some attachments to the “Follow” parts.
image


My issue is that I cannot add them in order; I originally had a for loop getting all the follow parts, but it didn’t do them in order.

At the moment, LastNode and NextNode are object values. Also, at each end of the part; there is an attachment called attachment0 and attachment1.

I’m struggling to add these; (I had an old script that generated a circle which I can give to you all if you want it.


Thanks,
Sasial.

2 Likes

It’s not really clear how your project is set up. Can you explain it better or post a screenshot of the Explorer window, showing exactly how the “Follow” parts and Last-/NextNode objects are laid out?

1 Like

The Follow parts are just in a node folder.
The Last and Next node will be generated in the script.
Instance.New("ObjectValue")

1 Like

Fixed an error with where the nodes are.

Generating Script (Old script which only generates a circle):
local SerStorage = game:GetService("ServerStorage")
local node = SerStorage.Node

local circleTable = {
	500
}

for k, r in ipairs(circleTable) do
	local offset = (k - 1) * 50
	--print(offset)
	for i = 1 + offset, 50 + offset do
		print(i)
		local newNode = node:Clone()
		
		local angle = CFrame.Angles(0, i * math.pi/25,0)
		
		newNode.CFrame = CFrame.Angles(0, i * math.pi/25,0) * CFrame.new(0,0,r)
		newNode.Name = tostring(i)
		
		local len = r * math.pi/25
		newNode.Size = Vector3.new(len, 1, 1)
		
		local node0 = Instance.new("Attachment") do
			node0.Position = Vector3.new(-len/2, 0, 0)
			node0.Name = "Node0"
			node0.Parent = newNode
		end
		local node1 = Instance.new("Attachment") do
			node1.Position = Vector3.new(len/2, 0, 0)
			node1.Name = "Node1"
			node1.Parent = newNode
		end
		local ntype = Instance.new("StringValue") do
			ntype.Parent = newNode
			ntype.Value = "Simple"
			ntype.Name = "Type"
		end
		local order = Instance.new("IntValue") do
			order.Parent = newNode 
			order.Value = i
			order.Name = "Order"
		end
		newNode.Parent = workspace.Nodes
	end
end

for i = 1,#workspace.Nodes:GetChildren() do
	local lastI = tostring((i - 2)%50 + 1)
	local nextI = tostring(i%50 + 1)
	local I = tostring(i)
	
	
	local current = workspace.Nodes[I]
	
	local lastFolder = Instance.new("Folder") do
		local part = workspace.Nodes[tostring(lastI)]
		
		local val = Instance.new("ObjectValue")
		val.Value = part
		val.Parent = lastFolder
		
		lastFolder.Name = "LastNode"
		lastFolder.Parent = current
	end
	
	local nextFolder = Instance.new("Folder") do
		local part = workspace.Nodes[tostring(nextI)]
		
		local val = Instance.new("ObjectValue")
		val.Value = part
		val.Parent = nextFolder
		
		nextFolder.Name = "NextNode"
		nextFolder.Parent = current
	end
	
end
1 Like

Is there anything else that is needed so it can be fixed?