I'm trying to make a conveyor belt like the ones in factorio. This is supposed to be the intended behaviour. This can be found in a roblox game: Manufactory
However this is my result of replicating the system: result
I have been playing around with my code to see if anything will change but none works. Here's my code:
-- movement of items from conveyor one to another
-- creates a new thread everytime a new conveyor is added
coroutine.resume(coroutine.create(function()
local heartbeat
local totalRun = 0
local pointLooping = false
local laneLooping = false
heartbeat = game:GetService("RunService").Heartbeat:Connect(function(dt)
if child and child:FindFirstChild("ItemsPerSecond") then
local nodes = child.Nodes -- where the lane are [left, right]
if not laneLooping then
local start = tick()
laneLooping = true
for _, lane in pairs(nodes:GetChildren()) do -- loops all nodes in the lane
pointLooping = true
coroutine.resume(coroutine.create(function() -- is here to make sure all lanes are looping together
for index = #lane:GetChildren(), 1, -1 do
coroutine.resume(coroutine.create(function() -- is here to make sure all nodes are
-- all nodes are attachments
local currentNode = lane:FindFirstChild("Node"..index)
local nextNode = lane:FindFirstChild("Node"..index - 1)
if nextNode then
if currentNode.Item.Value and nextNode.Item.Value == nil then
-- move current item to next node
tween(currentNode.Item.Value, {"Position"}, nextNode.WorldPosition, child.ItemsPerSecond.Value, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
nextNode.Item.Value = currentNode.Item.Value
currentNode.Item.Value = nil
end
else
local nextConveyor = child.NextConveyor.Value -- aka the front conveyor
if nextConveyor then
local connectionType = getConveyorConnection(child, nextConveyor) -- check how the conveyor are connected to each other
if connectionType == "Left" then
if lane.Name == "Left" then
nextNode = nextConveyor.Nodes.Left:FindFirstChild("Node1")
else
nextNode = nextConveyor.Nodes.Left:FindFirstChild("Node4")
end
elseif connectionType == "Right" then
if lane.Name == "Right" then
nextNode = nextConveyor.Nodes.Right:FindFirstChild("Node1")
else
nextNode = nextConveyor.Nodes.Right:FindFirstChild("Node4")
end
elseif connectionType == "Back" then
nextNode = nextConveyor.Nodes:FindFirstChild(lane.Name):FindFirstChild("Node4")
end
if currentNode.Item.Value and nextNode.Item.Value == nil then
-- move current item to next conveyor last node
tween(currentNode.Item.Value, {"Position"}, nextNode.WorldPosition, child.ItemsPerSecond.Value, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
nextNode.Item.Value = currentNode.Item.Value
currentNode.Item.Value = nil
end
end
end
end))
end
pointLooping = false
end))
end
repeat game:GetService("RunService").Heartbeat:Wait() until not pointLooping
--print("TIME TAKEN: " .. tick() - start)
laneLooping = false
end
end
end)
end))
If there anything else that needs clarification feel free to ask! Thanks in advance for any help! :D

6 comments
use custom physical properties?
errmmm? How would that help given my situation? Please explain.
I got a few Ideas either Unanchord those stones and make em untouchable or set the position of each one according to the Part it is on
That's is what the script is doing and the child.Item.Value is to check whether there is an item on that node before moving other item to said node. But now the problem is that all the items are tweening / moving to the node where there is no item on it and skipping the rest of the other node. It should by right move to the next node one by one instead of skipping as shown in the intended behavior
I am not sure if I get your question but would this wiki article work? https://developer.roblox.com/en-us/articles/Making-a-Conveyor-Belt
The link i have set up shows how's the conveyor works.