I tried making this function to a coroutine but...
module.Functions.Dispatch = coroutine.wrap(function(train, path, button)
if path == nil then return end
button.Text = path.Name
while wait() do
if path.Status == 0 then
button.TextColor3 = Color3.new(0, 170, 0)
button.Active = true
elseif path.Status == 1 then
button.TextColor3 = Color3.new(255, 255, 0)
button.Active = true
elseif path.Status == 2 then
button.TextColor3 = Color3.new(255, 0, 0)
button.Active = false
end
if train == nil then
button.Text = ""
button.Active = false
break
end
end
end)
when I call it multiple times, only the first one starts.
module.Functions.Dispatch(mod.QueuedTrain, mod.Paths[1], O1)
module.Functions.Dispatch(mod.QueuedTrain, mod.Paths[2], O2)
module.Functions.Dispatch(mod.QueuedTrain, mod.Paths[3], O3)
How can I run them at the same time? Thanks.

2 comments
Only one coroutine ever runs at a time
http://lua-users.org/wiki/CoroutinesTutorial