Logo de Roblox Luau

Roblox Luau

Comunidade
EL4CTEO
roblox-luau

Modern, type-safe Luau for Roblox, covering --!strict and the new type solver, generics, string interpolation, if-expressions, task library, require-by-string, module/OOP patterns, error handling with retries, buffer/vector, and legacy APIs to avoid. Use when writing, refactoring, or explaining any Roblox script, fixing type errors, or modernizing old Lua code.

Visão geral

Publicado porEL4CTEO
Repositórioroblox-skills
Nome da habilidaderoblox-luau
Estrelas
170
Forks
18
Arquivos incluídos
2
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Arquivos incluídos: 2

    Scripts, templates e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente para leitura e nunca são executados.

  • Código aberto

    Publicada por EL4CTEO no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Roblox Luau no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/EL4CTEO/roblox-skills/tree/main/skills/roblox-luau
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/EL4CTEO/roblox-skills.git /tmp/roblox-skills
mkdir -p .claude/skills
cp -r /tmp/roblox-skills/skills/roblox-luau .claude/skills/roblox-luau
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Roblox Luau em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Roblox Luau automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Roblox Luau não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Modern Luau for Roblox

Luau is Roblox's gradually-typed Lua 5.1 derivative. Engine and language move fast; many patterns from older tutorials (and older training data) are deprecated. Apply these defaults to every script you write unless the project clearly uses another convention.

Defaults for all generated code

  1. --!strict at the top of new ModuleScripts (and Scripts when practical). Type public functions.
  2. Get services with game:GetService("Name") at the top of the file, never game.Name.
  3. Use the task library: task.wait, task.spawn, task.defer, task.delay, task.cancel. Never wait, spawn, delay (deprecated, throttled, imprecise).
  4. Yielding engine calls that can fail (DataStore, HTTP, Marketplace, Teleport, *Async) go inside pcall.
  5. Prefer the *Async variants of APIs; Roblox renamed most yielding methods (LoadCharacterAsync, GetProductInfoAsync, UserHasBadgeAsync, ...). See the table below.
  6. Disconnect connections / destroy instances you create (see "Cleanup" below).
  7. Naming: PascalCase for services, modules, classes, types, and instance names; camelCase for locals and functions; SCREAMING_SNAKE_CASE for constants.
  8. Tabs for indentation (StyLua default in the Roblox ecosystem), double quotes.

Modern syntax cheat sheet

luau
local Players = game:GetService("Players")

local count = 0
count += 1 -- compound assignment: += -= *= /= //= %= ^= ..=

local label = if count > 1 then "many" else "one" -- if-expression (no `and/or` pitfalls)
print(`Player count: {#Players:GetPlayers()} ({label})`) -- string interpolation

for index, player in Players:GetPlayers() do -- generalized iteration: no pairs/ipairs needed
	if player.AccountAge < 1 then
		continue -- continue is a keyword
	end
	print(index, player.Name)
end

local half = 7 // 2 -- floor division → 3
local frozen = table.freeze({ Speed = 16 }) -- read-only table; writes throw
local list = table.create(100, 0) -- preallocated array
local copy = table.clone(frozen) -- shallow copy (unfrozen)
local mid = math.lerp(0, 10, 0.5) -- also: math.map, math.clamp, math.round, math.sign
print(half, list[1], copy.Speed, mid)
  • pairs/ipairs still work; generalized iteration is preferred and iterates arrays in order.
  • #t is only defined for arrays without holes. Setting t[i] = nil in the middle creates holes.
  • Numbers are doubles: integers are exact to 2^53. Use math.floor/// for integer math.
  • tick() is discouraged: use os.clock() for benchmarks, workspace:GetServerTimeNow() for synced time across clients/server, os.time()/DateTime.now() for wall-clock UTC.
  • Studio betas (not for published code yet): if local/if const bindings, now also while local/ while const (fresh narrowed binding per iteration, loop exits on nil/false); Luau Modularity: export values/functions/types from a module (exported module tables are frozen) and cyclic requires when every module in the cycle uses export. Enable under File → Beta Features before using them.

Types (new type solver)

Roblox's new type solver is generally available (Nov 2025) and Workspace.UseNewLuauTypeSolver controls it; Workspace.LuauTypeCheckMode sets the default mode. Write code that checks cleanly under --!strict.

luau
--!strict
export type Item = {
	id: string,
	name: string,
	stack: number,
	tags: { string }?, -- optional field
}

type Rarity = "Common" | "Rare" | "Legendary" -- singleton (literal) union

local function totalStack(items: { Item }, filter: ((Item) -> boolean)?): number
	local total = 0
	for _, item in items do
		if filter == nil or filter(item) then
			total += item.stack
		end
	end
	return total
end

local function first<T>(list: { T }): T? -- generics
	return list[1]
end

local rarity: Rarity = "Rare"
local part = workspace:FindFirstChild("Door") :: BasePart? -- cast with ::
print(totalStack({}, nil), first({ 1, 2 }), rarity, part)
  • Refine before use: if part then ... end, if typeof(x) == "Instance" and x:IsA("BasePart") then.
  • typeof(v) knows Roblox types ("Vector3", "Instance", ...); type(v) only knows Lua types.
  • Instance types come from IsA refinement or FindFirstChildOfClass/FindFirstChildWhichIsA.
  • Avoid any except at trust boundaries (remote payloads, decoded JSON) — validate there, then narrow.

Details: generics, type packs, read/write properties, user-defined type functions, typing OOP classes, and migrating legacy code to strict: references/type-system.md.

Modules and require

ModuleScripts run once per environment (server or each client) and return one value, cached for every later require. A module in ReplicatedStorage required by both sides runs twice, once per side, with separate state.

luau
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Signal = require(ReplicatedStorage.Packages.Signal) -- instance path (always works)
local Config = require("./Config") -- require-by-string: sibling of this script (script.Parent)
local Utils = require("@self/Utils") -- child of this script
local Shared = require("@game/ReplicatedStorage/Shared") -- absolute from game
print(Signal, Config, Utils, Shared)
  • String paths: ./ = script.Parent, ../ = script.Parent.Parent, @self/ = script, @game/ = game. They do not wait for instances to exist. Use instance paths with WaitForChild when the module may not have replicated yet.
  • Never create circular requires; they deadlock/error. Break cycles with dependency injection or events.
  • Don't yield at module top level (no WaitForChild chains on things that may never exist, no DataStore calls): every requirer blocks until the module returns.

Module / class pattern

luau
--!strict
local Counter = {}
Counter.__index = Counter

export type Counter = typeof(setmetatable({} :: { value: number, step: number }, Counter))

function Counter.new(step: number?): Counter
	return setmetatable({ value = 0, step = step or 1 }, Counter)
end

function Counter.increment(self: Counter): number
	self.value += self.step
	return self.value
end

return Counter

Prefer plain modules of functions + data tables over deep inheritance. Use composition.

Errors and retries

luau
local DataStoreService = game:GetService("DataStoreService")
local store = DataStoreService:GetDataStore("PlayerData")

local function retry<T...>(attempts: number, fn: () -> T...): (boolean, T...)
	local delaySeconds = 1
	for attempt = 1, attempts do
		local result = table.pack(pcall(fn))
		if result[1] then
			return table.unpack(result, 1, result.n)
		end
		if attempt < attempts then
			warn(`attempt {attempt} failed: {result[2]}`)
			task.wait(delaySeconds)
			delaySeconds *= 2 -- exponential backoff
		end
	end
	return false
end

local ok, data = retry(3, function()
	return store:GetAsync("Player_1")
end)
print(ok, data)
  • error("message", 2) blames the caller; error({ code = "X" }) throws a table for structured errors.
  • xpcall(fn, debug.traceback) keeps the stack trace.
  • Don't wrap everything in pcall — only calls that can fail for reasons outside your code.

Concurrency: the task library

CallBehavior
task.spawn(fn, ...)Run now (until first yield) on a new thread.
task.defer(fn, ...)Run at the end of the current resumption cycle. Good for "after this finishes".
task.delay(t, fn, ...)Run after t seconds. Returns a thread you can task.cancel.
task.wait(t?)Yield ≥ t seconds (one frame if omitted); returns elapsed time.
task.cancel(thread)Stop a spawned/delayed thread.
task.desynchronize() / task.synchronize()Parallel Luau (inside Actors) — see roblox-performance.
  • Per-frame work: RunService.Heartbeat (after physics), RunService.PreSimulation/PostSimulation, RunService:BindToRenderStep (client, before render, ordered). Don't while true do task.wait() end for per-frame logic; connect to an event and use its deltaTime.
  • Write handlers that work under deferred signal behavior (Workspace.SignalBehavior): handlers run later in the frame, not inline. New template places use Deferred, Default will switch to it, and server authority requires it. Don't rely on handler side effects being visible right after :Fire().
  • Never yield inside metamethods or Changed-style callbacks that must be synchronous.

Cleanup (memory leaks are the #1 Roblox bug)

luau
local Players = game:GetService("Players")

local connections: { RBXScriptConnection } = {}

table.insert(
	connections,
	Players.PlayerRemoving:Connect(function(player)
		print(`{player.Name} left`)
	end)
)

local function cleanup()
	for _, connection in connections do
		connection:Disconnect()
	end
	table.clear(connections)
end

cleanup()
  • Instance:Destroy() disconnects that instance's connections and locks Parent; it does not clear your Lua references — nil out tables that hold players/instances on PlayerRemoving.
  • Use :Once() for one-shot connections. Use a Trove/Janitor/Maid-style helper for groups.
  • Keys that are Player/Instance objects in long-lived tables leak unless removed on leave/destroy.

Buffers and vectors (performance-sensitive data)

luau
local packet = buffer.create(10)
buffer.writeu16(packet, 0, 513) -- item id
buffer.writef32(packet, 2, 12.5) -- amount
buffer.writei32(packet, 6, -4)
print(buffer.readu16(packet, 0), buffer.readf32(packet, 2), buffer.len(packet))

local v = vector.create(1, 2, 3) -- native 3-float vector (same type as Vector3 at runtime)
print(vector.magnitude(v), vector.normalize(v), vector.dot(v, vector.one))

buffer is the right tool for compact network payloads, large grids, and binary serialization. buffer.readvectorf32x3(b, offset) / buffer.writevectorf32x3(b, offset, v) (and the x2 variants, Z = 0) move a whole vector in one instruction, 2-3× faster than three readf32/writef32 calls. SerializationService:SerializeValue(value) / :DeserializeValue(b) turn a Luau value into a buffer and back. Standard-library quick reference: references/stdlib-cheatsheet.md.

Legacy → current (most common mistakes)

Don't writeWrite instead
wait(), spawn(), delay()task.wait(), task.spawn(), task.delay()
game.Workspace, game.Playersworkspace, game:GetService("Players")
Instance.new("Part", parent)create, set properties, then set .Parent last
Humanoid:LoadAnimation()Animator:LoadAnimation()
Model:SetPrimaryPartCFrame()Model:PivotTo() / Model:GetPivot()
workspace:FindPartOnRay(Ray.new(...))workspace:Raycast(origin, direction, params)
BodyVelocity, BodyPosition, BodyGyroLinearVelocity, AlignPosition, AlignOrientation
player:LoadCharacter()player:LoadCharacterAsync()
MarketplaceService:GetProductInfo():GetProductInfoAsync()
BadgeService:AwardBadge():AwardBadgeAsync()
player:GetRankInGroup()GroupService:GetRolesInGroupAsync() / player:IsInGroupAsync()
TeleportService:Teleport*() variantsTeleportService:TeleportAsync()
Chat service / ChatService modulesTextChatService
GuiObject.DraggableUIDragDetector
table.getn, table.foreach, getfenv#t, for ... in, nothing

The full deprecation map lives in the roblox-code-review skill.

Performance idioms (only where it matters)

  • Measure first (debug.profilebegin/profileend, MicroProfiler, Script Profiler).
  • --!native at the top of a script, or @native on a function, compiles hot numeric code natively. Use it on math-heavy modules, not everywhere (compile time + memory limits). Type annotations help it, and since Studio 747 native code also re-specializes hot paths for the types it actually sees.
  • Cache Instance lookups and service references outside loops; avoid FindFirstChild chains per frame.
  • Build large strings with table.concat or buffer, not repeated .. in loops.
  • Reuse RaycastParams/OverlapParams objects instead of creating them per call.

Related skills

roblox-architecture (project structure, client/server), roblox-networking (remotes), roblox-performance (profiling, Parallel Luau), roblox-code-review (review checklist, full deprecation map).

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Roblox Luau faz?

Modern, type-safe Luau for Roblox, covering --!strict and the new type solver, generics, string interpolation, if-expressions, task library, require-by-string, module/OOP patterns, error handling with retries, buffer/vector, and legacy APIs to avoid. Use when writing, refactoring, or explaining any Roblox script, fixing type errors, or modernizing old Lua code.

Por que usar Roblox Luau no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Roblox Luau é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Roblox Luau no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/EL4CTEO/roblox-skills/tree/main/skills/roblox-luau. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Roblox Luau?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Roblox Luau?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Roblox Luau com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Roblox Luau é gratuita?

Sim. A habilidade é publicada no GitHub por EL4CTEO sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇