I need help with this conveyor behavior problem
The bug is pretty weird, and RNG, it sometimes work, it sometimes doesn’t work. I don’t know what exactly caused it. I even set up a macro to do the exact something, but even that yields different result. I could place only 3 conveyors and get the bug, or place 50 without encountering it. Honestly, I’m just so tired of this.
I did modify the code below me to use fixed step for more stable delta time, move the movement logic to client side, etc. But even with that it still doesn’t work.
Previous code:
local conveyorConn = RunService.Heartbeat:Connect(function(dt)
for _, conveyor in conveyorsDataList do
local item = conveyor.Item
local nextConveyor = ConveyorController.get("model", conveyor.NextConveyor)
if item and nextConveyor and not nextConveyor.TempItem and conveyor.Elapsed < 1 then
conveyor.Elapsed += conveyor.Speed * math.min(dt, 0.1) * textureConveyorSpeedRatio
conveyor.TempItem = nil
local alpha = math.clamp(conveyor.Elapsed, 0, 1)
moveItemToNextConveyor(alpha, item, conveyor.MainModel, nextConveyor.MainModel)
if alpha >= 1 then -- When item is fully moved then:
nextConveyor.Item = item
nextConveyor.TempItem = item
conveyor.Item = nil
conveyor.Elapsed = 0
end
end
end
end)
Improved code, that still doesn’t work :
local fixedStep = 1/60
local accumulator = 0
local lastTime = time()
RunService.Heartbeat:Connect(function()
local now = time()
local dt = now - lastTime
lastTime = now
accumulator += dt
local steps = 0
local movesBatch = {}
while accumulator >= fixedStep and steps < 5 do
-- Process conveyor logic
for _, conveyor in table.clone(conveyorsDataList) do
--[[if not conveyor.Item and conveyor.TempItem then
conveyor.TempItem:Destroy()
conveyor.TempItem = nil
end--]]
local item = conveyor.Item
local nextConveyor = ConveyorController.get("model", conveyor.NextConveyor)
if item and nextConveyor and not nextConveyor.TempItem and conveyor.Elapsed < 1 then
if conveyor.Elapsed == 0 then
print("test", nextConveyor.TempItem)
conveyor.TempItem = nil
local okStart, startCF = pcall(function()
return item.PrimaryPart and item.PrimaryPart.CFrame
end)
local okEnd, endCF = pcall(function()
return getItemEndCFrame(item, nextConveyor.MainModel)
end)
local duration = (conveyor.Speed and conveyor.Speed > 0) and
(1 / (conveyor.Speed * textureConveyorSpeedRatio)) or 1
if okStart and okEnd and startCF and endCF then
table.insert(movesBatch, {
Item = item,
Start = startCF,
End = endCF,
Duration = duration
})
end
end
conveyor.Elapsed = math.min(
conveyor.Elapsed + conveyor.Speed * fixedStep * textureConveyorSpeedRatio,
1
)
if conveyor.Elapsed >= 1 then
nextConveyor.Item = item
conveyor.Item = nil
nextConveyor.TempItem = item
conveyor.Elapsed = 0
moveItemToConveyor(item, conveyor.NextConveyor)
end
end
end--]]
accumulator -= fixedStep
steps += 1
end
if #movesBatch > 0 then
pcall(function()
RE.Conveyors.TweenItem:FireAllClients(movesBatch)
end)
end
end)
btw this is the logic for sending item
Example ID 1 wants to send to ID 2
check if ID2 has tempitem (not item), if no then set tempitem of ID1 to false and ID2 to true, after done moving, it will actually move the item, ID1 item = false, ID2 item = true
On normal occasion it should the progress should look like this :
{item, tempitem}
ID1 → exist exist
ID2 → nil nil
ID1 said oh alright tempitem on ID2 is nil, I’ll move my tempitem to him, and I should take a note that transferring will take time and not instant
ID1 → exist nil
ID2 → nil exist
ID1 said, ohh my time has come, alright goodbye item!
ID1 → nil nil
ID2 → exist exist
POSSIBLE BUGS? (Another Case)
Item x → moving to conveyor a
Item y → moving to conveyor b
Item z → moving to conveyor c
At the same time, it loops through every conveyor and then move item to next conveyor
ID x move to a (normal)
ID z move to c (normal)
ID y, after finish moving to b, it jumps straight to id c, and it overwrites item Z
Extra note:
f next conveyor has an item but tempitem is nil it will still move item to that conveyor, that’s what it makes the item overrides
not hell (3).rbxl (123.3 KB)
Thanks if anyone managed to read all of this, hopefully I can fix this bug soon

