Home › Roblox (Luau) › Roblox Luau rules

Roblox Luau rules

Cursor rules for Roblox experiences in Luau: strict typing, client/server boundaries, remotes, and data saving.

CursorRoblox (Luau)

How to use

Save this as .cursor/rules/roblox.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/roblox.mdcDownload  
---
description: Roblox Luau conventions
globs: ["src/**/*.{lua,luau}"]
alwaysApply: false
---

# Roblox (Luau)

- Start every script with `--!strict` and type function signatures and tables (`type PlayerData = { coins: number }`).
- Get services with `game:GetService("Players")`, never `game.Players`.
- Project layout via Rojo (`default.project.json`): `src/server` -> ServerScriptService, `src/client` -> StarterPlayerScripts, `src/shared` -> ReplicatedStorage. Shared logic in ModuleScripts.
- The server is authoritative. Clients only send intent through RemoteEvents/RemoteFunctions; the server validates every argument (type, range, cooldown, ownership) before acting.
- Never trust client values for currency, damage, or position. Don't use `RemoteFunction:InvokeClient`.
- Use `task.wait`, `task.spawn`, `task.delay`, never `wait()`/`spawn()`/`delay()`.
- Clean up connections: store them and `:Disconnect()` them, or use a Trove/Maid if the project has one.
- DataStores: wrap calls in `pcall`, use `UpdateAsync` for changes, save on `PlayerRemoving` and `game:BindToClose`, and respect request budgets. Use a session-locking library (ProfileStore) if present.
- Use `RunService.Heartbeat` for per-frame logic only when needed; avoid busy loops.
- Prefer `Instance.new` + setting `Parent` last.

## Done when
Selene (`selene src`) and StyLua (`stylua --check src`) pass and the change was tested in a Studio play session.

More: all Roblox (Luau) rules · all Cursor rules

Related rules

Godot 4 C# rules

Cursor rules for Godot 4.x games written in C# (.NET 8): node scripts, signals, exports, and performance.

CursorGodot

LÖVE (Love2D) Lua game rules

Cursor rules for 2D games with LÖVE 11.5 in Lua: callbacks, modules, delta time, asset loading, and performance.

CursorLÖVE (Love2D)

Three.js rules

Cursor rules for Three.js (r17x, ES modules) web 3D and games: render loop, disposal, assets, and performance.

CursorThree.js

Unity C# game dev rules

Cursor rules for Unity 6 projects in C#: performance, MonoBehaviour lifecycle, ScriptableObjects.

CursorUnity (C#)

Unity DOTS / ECS rules

Cursor rules for Unity Entities 1.x (DOTS): baking, ISystem with Burst, jobs, IJobEntity, and structural changes.

CursorUnity (C#)

Unreal Engine 5 C++ gameplay rules

Cursor rules for Unreal Engine 5 gameplay C++: UObject reflection, TObjectPtr, Enhanced Input, components, and Blueprint APIs.

CursorUnreal Engine (C++)

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.