Scripting Basics (Luau)
Roblox scripts use Luau, derived from Lua 5.1, with gradual typing and analysis tools. You manipulate Instances (objects in the data model), connect to events, and call methods on services.
| Concept | Example |
|---|---|
| Variables & Types | local coins:number = 0 local name:string = "Player" |
| Functions | local function add(a:number,b:number):number return a+b end |
| Events | workspace.Part.Touched:Connect(function(hit) print("Touched by", hit.Name) end) |
| Services | local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") |
| Modules | -- ModuleScript local M = {}; function M.greet(n) return "Hello, "..n end; return M |
Client vs Server: Use LocalScript for UI/input/camera, and Script (server) for data, security, and authoritative gameplay.