Node System Help Needed

  1. What do you want to achieve?
    Node generation, and where all the values update correctly.

  2. What is the issue?
    At the moment I have received an error. (Attached)

  3. What solutions have you tried so far?
    I asked a friend, and they had no idea.

local nodes = script.Parent.Nodes

function createNode(order, NodeRef, alignment)
local node = Instance.new("Part")
node.Anchored = true
node.CanCollide = false
node.Name = "Node" .. order
node.Parent = nodes
node.CFrame = nodeRef.CFrame * CFrame.new(0,0,alignment * nodeRef.Size.Z/2)
node.Size = Vector3.new(1,1,1)

local nextNode = Instance.new("ObjectValue")
nextNode.Parent = node
nextNode.Name = "NextNode"

local prevNode = Instance.new("ObjectValue")
prevNode.Parent = node
prevNode.Name = "PreviousNode"
end

for order, nodeRef in ipairs(nodes:GetChildren())
createNode(order, nodeRef, 1)
if order == (#nodes:GetChildren() - 1) then
createNode(order +1, nodeRef, -1)
end
nodeRef:Destroy()
end

for _, node in pairs(nodes:GetChildren()) do
local nextNode = node.NextNode
local prevNode = node.PreviousNode

local order = tonumber(string.split(node.Name, "_")[2])

if nodes:FindFirstChild("Node_" .. order + 1) then --// This appears to be the line of error
nextNode.Value = nodes:FindFirstChild("Node_" .. order + 1)
end
if nodes:FindFirstChild("Node_" .. order - 1) then
prevNode.Value = nodes:FindFirstChild("Node_" .. order - 1)
end

if script.Parent.Loop.Value then
if order == 1 then
prevNode.Value = nodes:FindFirstChild("Node_" .. order + #nodes:GetChildren())
elseif order == #nodes:GetChildren() then
nextNode.Value = nodes:FindFirstChild("Node_1")
end
end
end

script.Parent.NodeReady.Value = true

The error:

These values need to update:
image

What happens currently:
image

The workspace:
image

The red dots are nodes:

Which line is no. 35? And please don’t scale screenshots so tiny xD

That above is number 35 ^, and if you want screenshots bigger just click on them. Theyre smaller to make the post look cleaner

So I got told:

basically order is just nil
it cant make whatever youre feeding it into a number

How would I make order turn something into a number then?

Show the nodes folder content so we get more context.

The nodes folder content is literally just blocks named ‘NodeReference’, when the game loads they all go and all the nodes spawn normally.