roblox-luau
Use when writing, fixing or reviewing Luau: task scheduling, coroutines, connections and leaks, metatables, buffers, types and strict mode.
How do I install this agent skill?
npx skills add https://github.com/tabooharmony/roblox-brain --skill roblox-luauIs this agent skill safe to install?
- Gen Agent Trust Hubpass
This skill provides technical guidance and best practices for Roblox Luau programming, including task scheduling, type checking, and performance optimization. It includes references to official Roblox and Luau documentation.
- Socketpass
No alerts
- Snykwarn
Risk: MEDIUM · 1 issue
What does this agent skill do?
Roblox Luau
Scope
Luau where scheduling, cleanup, metatables, buffers or the type checker can bite. Run contexts, load order and require scope: roblox-architecture; hot paths: roblox-performance; luau-lsp/Selene/StyLua: roblox-tooling; bug hunts: roblox-debugging.
"Probed" = run on the Luau runtime or luau-analyze that date; "field case" = seen in the owner's projects.
Traps and review checklist (symptom -> cause -> fix)
- Error in background code vanishes ->
coroutine.resumecatches it and returnsfalse, err; an errored thread's status is"dead", same as a finished one.coroutine.wrapre-raises into the caller. Check resume's first return, or start work withtask.spawn. - Queued worker handles one job per run, budget never trips ->
task.spawnruns the function now, before the caller's next line;task.deferruns at the end of the current resumption cycle. Start batch workers withtask.defer(field case, §1). - Loop slower than asked, or
local a, b = wait()-> deprecatedwait/spawn/delaythrottle (29 ms minimum, more under load);waitreturns(elapsed, engineTime).task.wait(t)resumes on the first due Heartbeat and returns elapsed only;task.wait()=Heartbeat:Wait(). Use the returneddt, not the requested time. - Duplicate handlers or growing memory after respawn -> a
CharacterAddedhandler connects to something long-lived (RunService,Players, a remote, thePlayer) and never disconnects.Destroy()disconnects only that instance's connections, and old characters are destroyed only withWorkspace.PlayerCharacterDestroyBehaviorenabled. Track connections per owner, disconnect onCharacterRemoving/Destroying;:Once()for one-shots. - Grid lookup returns
nil, no error ->Vector3keys hash by value,Vector2keys by identity (field-measured). Key 2D cells byVector3.new(x, 0, z). table is already frozenkills a module at require -> re-freezing errors;table.freeze/table.cloneare shallow and the clone is unfrozen. Freeze once at creation or checktable.isfrozen.- Proxy table misbehaves ->
__newindexfires only for keys absent from raw storage;pairs,table.insert,table.concatread raw storage, there is no__pairs(generalizedforuses__iter);__eqruns only when both sides share one handler, and even forx == x(probed 2026-10). Keep the proxy empty, data in a backing table. - Buffer data silently wrong -> out-of-bounds errors, but an in-bounds wrong-width read succeeds (
readu16on au32slot), integer writes keep the low bits (writeu8(b, 0, 300)stores 44),f32rounds (probed 2026-10). Little-endian, 0-based. Keep offsets and widths in named helpers. - Decompression bomb from a client ->
EncodingService:DecompressBuffertrusts the size header (up to 1 GB). CallGetDecompressedBufferSizefirst; refusenilor oversize. --!nativegives no client speedup -> it runs only for server scripts and Android clients;getfenv/setfenvand arguments violating annotated types drop to the interpreter; past the code-size limit the rest runs interpreted. Annotate hotVector3params; no official speedup figure, measure (roblox-performance).
Type checker traps
- Type error "suddenly" in unchanged code -> the solver switched:
Workspace.UseNewLuauTypeSolveris aRolloutStateandDefaultfollows the engine rollout (LuauTypeCheckModeis strictness, not solver). Repro under both solvers. - New-solver syntax flagged unknown ->
keyof,setmetatable<T, M>as a type,type function,read/writeproperties need the new solver. Don't delete them to appease an old-solver tool, and don't add them to an old-solver project (there:typeof(setmetatable({} :: Data, Class))). - Narrowed field wrong after a call -> refinements on
t.fieldare fragile and differ per solver. Copy to a local, narrow that.
Limits
| Item | Value |
|---|---|
Legacy wait/spawn/delay | 29 ms minimum |
StringValue.Value | 200,000 chars (String too long) |
What changed
| Change | Use now |
|---|---|
tick() (untagged; off up to 1 s, varies by time zone/OS) | os.clock(), os.time()/DateTime, workspace:GetServerTimeNow() |
const (Luau 0.711) <!-- temporal: 2026-03 --> | freezes the binding, not the table; older linters reject it |
buffer.readvectorf32x3/writevectorf32x3, readvectorf32x2/writevectorf32x2 <!-- temporal: 2026-11 --> | Vector3 as f32; x2 reads Z as 0 |
coroutine.finally(co, cb) <!-- temporal: 2026-10 --> | cleanup on "finished"/"error"/"cancelled"; errors on a dead or wrap coroutine |
EncodingService <!-- temporal: 2026-08 --> | Base64Encode, CompressBuffer (Zstd), ComputeStringHash (not for passwords) on buffers |
1. Frame-sliced work (field-measured)
- Start a budgeted queue with
task.defer; check the budget inside each step, not between big steps (worst frame 310 -> 57 ms). - A system pinned at its budget with 0 completions is a stuck loop: count completions, add a no-progress guard.
task.delay(0, ...)from a paced start-up lands on top of the next system; push it clearly past start-up.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/tabooharmony/roblox-brain/roblox-luau">View roblox-luau on skillZs</a>