ok so I kinda wanna run 4 parallel functions that each wait for each other before continuing. how would I go about this.
uwu
ok so I kinda wanna run 4 parallel functions that each wait for each other before continuing. how would I go about this.
uwu
You can Clone()
and set the position then run a function.
``-- I’m not fully sure about this cause I’m sleepy now
local function O()
game.Workspace.Part:Clone()
– Sorry im tired
end
O()
Use coroutines and each one wait for four physical variables to be set to true.
local finished = {false,false,false,false}
function passSomeTime(myNumber)
local myWaitTime = math.random(5) -- max 5 seconds wait time
wait (myWaitTime)
print "I finished!"
finished[myNumber] = true
end
for i = 1,4,1 do
coroutine.wrap(function() passSomeTime(i) end)() -- a subroutine will execute on its own
end
while wait() do
for _,bool in ipairs(finished) do
if bool==false then continue end
end
break -- we are done
end
print "Everyone is done!"
I don’t think we need coroutines? It to connect scripts
sorry I think you misunderstood the question
what I meant is that 4 functions run in parallel (utilizing the new parallel lua) then wait until they are all done then proceeding to the next part of the script.
also sleep is good C:
uwu
From what I understood it’s functions. I’m assuming within one script but same concept could be applied if you clone the script, then each script sets a respective variable to true when its done, then have an outside source checking when all the 4 variables are set to true to continue.
Ah I see. You want to multithread. I’m a bit inexperienced in parallel programming right now (taking a course in that this coming quarter actually), but as far as I know it’s only a preview right now? Only resources I could find for you is this.