I am currently programming a voxel game and trying to pipeline my code for chunk generation. I am unsure how I can write Parallel Lua in the same script if there is a way. What I understand about Parralel Lua is that it makes the whole script run in a different thread, Parallel to other scripts. So I’m wondering if there is some way to run parallel threads in the same scripts. Would using ConnectParallel run multiple threads for the same script in parallel?
local BindableEvent = script.Parent.Event
local BindableEvent2 = script.Parent.Event2
--thread one
BindableEvent:Fire()
--generate
BindableEvent.Event:ConnectParallel(function()
--Compress
BindableEvent2:Fire()
end)
BindableEvent2.Event:ConnectParallel(function()
--render
end)
Parallel lua requires scripts within many actors so there’s not really a way to do it in one script since each actor is 1 core, you could use the SendMessage function to easily parallelize everything across a lot of actors (no matter how many times you use connectparallel in one actor it will still use 1 core for that actor)
this explains it well: Parallel Luau | Documentation - Roblox Creator Hub