Could someone from Core team confirm the following assumptions:
All tasks are executed in a single CPU thread, hence all variables are thread-safe. I'm assuming this is the case because API doesn't include synchronization primitives.
LUA Scripts in the world hierarchy is guaranteed to be executed from top to bottom. Foremost script is always executed first.
Server-side basically functions like this: LUA scripts are collected from top to bottom. A Task is spawned for each of the scripts where they get executed one by one. If a variable is defined as global then that variable is added to global LUA table for the duration of the game and can be accessed by other scripts.
Thanks a lot.
For Question 2, it is safe to assume that scripts execute from top to bottom (I have tested this multiple times). You can change when events are executed using the priority attribute of hook listeners.
For question 3, a task is not spawned for each script. Multiple scripts will often run on the same task thread. You can test this by using Task.Wait() to determine which scripts are being blocked on one thread. You can define Global Variables using the _G table. However, these global variables would still follow client context and server context rules meaning there would be two global variable tables, one for client context and one for server context. These variables will be stored as long as the server/client instance of your game is running.