Scripting lets you add custom, dynamic behavior to your experiences, providing more engaging and immersive interactions for your users. Luau is the scripting language supported by Roblox, and you use it to build functionality within the Roblox engine.


Scripts are containers that hold Luau code, and can run on the server and client in isolation or across the network boundary. The data model has separate containers for client-side and server-side scripts to ensure security. You also typically parent scripts to other 3D objects to associate the objects with their associated logic.


Services are special singleton classes that provide convenient functionality for various underlying systems in the Roblox engine, such as input handling, sound management, and physics simulation, so you don't have to implement them from scratch.


Scripting on Roblox is primarily event-driven. However, you can still execute scripts in other ways, such as per-physics frame or per-rendering frame or even run scripts in a multithreaded environment.


Event connections allow your code to listen for built-in events fired by Roblox or custom events that you create. You can set up scripts to run automatically when the events occur by connecting them to the desired events, such as user input, a player touching a part, or a player spawning.


To facilitate scripts communicating across the client-server boundary, you can use remote events for one-way communication, allowing the server to send events to clients and vice versa, or remote callbacks for two-way communication, allowing scripts to make requests and wait for responses.

Task Scheduling

Task scheduling lets you explicitly run code at certain times during the Roblox engine's execution lifecycle. This pattern gives you more fine grained control over when code runs and is commonly used to animate objects, update the physics simulation, or to pause and run arbitrary code. You should schedule tasks only when necessary as you run the risk of overloading the scheduler.


Multi-threading can be helpful for optimizing CPU-intensive operations or implementing certain game mechanics that require parallel processing. Only use multithreading for tasks that require it to avoid potential issues such as race conditions or deadlocks.