Roblox and Luau

Luau additions: gradual typing (--!strict, --!nonstrict), type aliases, generics, continue, compound assignment, string interpolation with backticks, if-then-else expressions, the task library (task.wait, task.spawn, task.delay), native code generation, and a strong sandbox.

Roblox architecture: client/server model (Script vs LocalScript vs ModuleScript), RemoteEvents/RemoteFunctions (never trust the client!), DataStoreService (persistence), services (Players, ReplicatedStorage, TweenService, RunService).

Tools: Roblox Studio, Rojo (sync files with Studio for Git workflows), Wally (package manager), Selene/StyLua, luau-lsp.

-- Server Script (ServerScriptService): Luau with type annotations
local Players = game:GetService("Players")

local STARTING_COINS: number = 100

local function onPlayerAdded(player: Player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local coins = Instance.new("IntValue")
    coins.Name = "Coins"
    coins.Value = STARTING_COINS
    coins.Parent = leaderstats

    player.CharacterAdded:Connect(function(character)
        local humanoid = character:WaitForChild("Humanoid") :: Humanoid
        humanoid.Died:Connect(function()
            coins.Value -= 10                       -- compound assignment (Luau)
            print(`{player.Name} died! Coins: {coins.Value}`)   -- string interpolation (Luau)
        end)
    end)
end

Players.PlayerAdded:Connect(onPlayerAdded)

-- Touch part to collect a coin
local part = workspace:WaitForChild("Coin")
part.Touched:Connect(function(hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        player.leaderstats.Coins.Value += 1
        part:Destroy()
    end
end)