Moving scripts from the earlier API
Dialect replaced the earlier scripting API, and scripts written for it do not run. Most of the difference is updated names and a few design changes covered below.
API equivalents
| Earlier | Dialect |
|---|---|
Vector3.new(x, y, z) | vec(x, y, z) |
Color3.fromRGB(r, g, b) | rgb(r, g, b) |
Color3.new(r, g, b) | vec(r, g, b) (0 to 1) |
:Connect(fn), :On(fn) | :connect(fn) |
:Once, :Wait, :Disconnect, :Off | :once, :wait, :disconnect |
task.wait(n), wait(n) | sleep(n) |
task.spawn(fn) | scope:spawn(fn) |
task.delay(n, fn), task.every(n, fn) | scope:after(n, fn), scope:every(n, fn) |
workspace.Door | world.root:find("Door") |
Players.PlayerAdded, Players.PlayerRemoving | world.joined, world.left |
Players:GetPlayers() | world:query { class = Player }:entities() |
PlayerTouched | stepped_on |
.Position, .Size, .Color, .Transparency, .Anchored, .Name, .Parent, .Health | the same names in lower case |
.CanCollide | .solid |
.UserId | .user_id |
:FindFirstChild, :FindChild | :find |
:GetChildren() | :children() |
:Teleport, :Kick, :Play, :Stop, :Destroy | lower case |
| (no directive) | --!server for a Script, --!client for a LocalScript, --!module for a ModuleScript |
Strings and comments are never changed.
Patterns to update
| Earlier | What to do |
|---|---|
script.Parent | A script is a file now, not something inside a part. Find the part by name: world.root:find("Name"). |
Instance.new("Part"), Instance.Create | Part.new { name = ..., position = ... }: the properties go in the table. |
workspace:Raycast, GetPartsInSphere | world:raycast { ... }, world:query { within = ... }. |
TweenTo | entity:tween({ ... }, seconds). |
RemoteEvent, RemoteFunction and their calls | net.message(name, fields): see Client scripts and interface. |
DataStore, leaderstats | store(name): see Saved data. |
ScreenGui and friends | ui.label and ui.button in a --!client script. |
game:GetService(...) | Services are gone: world, store, net and the other globals do their work. |
CFrame | Gone. Positions and rotations are vectors (rotation is degrees about each axis). |
| Humanoids, rigs, tools, the backpack, seats, welds, attachments, joints, animations, particles and effects, decals, mesh parts | Gone from the game. Players have health, position and teleport. Kill bricks, checkpoints, jump pads, teleporters, buttons, conveyors and spinners are gone too: write them with touched and stepped_on signals. |
The ideas that changed
Three differences are bigger than names:
- Time belongs to scopes. A loop
while true do wait() endkeeps running after its part is gone. Usescope:every(seconds, fn), and it ends with the script, or withentity.scopeand it ends with the part. See Signals, scopes and time. - A script is a file. It says where it runs with a directive (
--!server,--!client,--!shared,--!module), and finds its parts by name instead of by sitting inside them. - Ask the world, then act on the answer. Instead of looping over parts and setting each,
world:query { ... }:set("color", c)does it in one call. See The world.
