Questions Regarding Script Signals & Roblox's Thread Scheduler

Hello,

I’m curious how exactly Roblox’s thread scheduler works, specifically as to how it handles threads initialized by script signals (i.e. functions used with the RBXScriptSignal:connect(f) API).

From what I can gather, all threads initiated by coroutine.resume and spawn run one at a time, uninterrupted by any other processes related to the script(s), until “wait()” is invoked, “coroutine.yield()” is called, or the thread function simply returns. Am I correct so far?

Now, when a script signal events are invoked, say, for instance, the “.Touched” signal for parts, does the same logic apply? Do the threads initiated by this event run one at a time (assuming no yielding within the invoked function) regardless of whether the “.Touched” event is called again before the invoked function has returned?

Moreover, does this logic apply between both script signal threads and threads explicitly initiated by the scripter via coroutine.resume, spawn(), etc? For instance, say we have some global variable, a coroutine thread with a “while wait() do” loop which requires that said global variable remain unchanged by anything other than itself throughout its execution, and a function invoked by some script signal that modifies that variable. Can one safely assume that said global variable will not be modified by anything but the coroutine while the coroutine is running?

Any insight will be greatly appreciated!

I have found answers to my questions by searching the forum.

So… If we need to know what the solution is would you please give us some information from that or at least what you did search for.

1 Like

My bad, I should have posted a link. Here is the post I found: Do connected functions run relatively at the same time?

Kiriot22 answered my questions as well.

1 Like