What im trying to do is loop through workspace and serverstorage at the same time. So is it possible?
COMMUNITY QUESTION
Is it possible to loop through two things at once?
1 answer
Yes this is possible. I would recommend using coroutines.
Example:
local firstLoop = coroutine.wrap(function()
for _,v in pairs(game.Workspace:GetChildren()) do
print(v.Name)
end
end)
firstLoop()
local secondLoop = coroutine.wrap(function()
for _,v in pairs(game.ServerStorage:GetChildren()) do
print(v.Name)
end
end)
secondLoop()
Coroutines basically allow code to run without having to yield the code after it.
Here's some more info if you need more help: https://developer.roblox.com/en-us/api-reference/lua-docs/coroutine
2 comments
0
No, it is not possible, coroutines are not new threads.
0
It is possible o3o, I tried it.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
what do u mean?
Im talking about a for loop. For example for i,v in pairs (game.Workspace, game.ServerStorage()) do. IF there is something like this.
for both im one loop
coroutines or nested loops to create a matrix web
how to delete another persons comment