Actors
Discover parallel Actors, run source code inside their state, and open BindableEvent-backed channels across state boundaries.
Roblox runs Actor instances in separate Luau states so their scripts can run in parallel. Those states are separate from yours, so code you want to run inside one has to be sent as source, not as a function.
The Guide: Actors & Parallel Luau chapter goes through a full example. Quick version:
Getting code into an actor
local actor = getactors()[1]
local id, channel = create_comm_channel()
channel.Event:Connect(function(...)
print("from the actor:", ...)
end)
run_on_actor(actor, ([[
local channel = get_comm_channel(%d)
channel:Fire("hello", isparallel())
]]):format(id))