: (type / protected call)
Two jobs: types on names, and Safe Mode calls that cannot crash the script.
Syntax
Section titled “Syntax”age: int = 10;void Greet(player: Player) { }
player:Kick();auto child = workspace:FindFirstChild("x");Parameters
Section titled “Parameters”None.
Return value
Section titled “Return value”For a call: the result on success, nil on error. The script keeps running.
Luau emit
Section titled “Luau emit”local age: number = 10
(function() local _ok, _r = pcall(function() return player:Kick() end) return if _ok then _r else nilend)()Description
Section titled “Description”Types. Prefix C++ types still work (int age = 10). : is the other spelling: age: int = 10, and name: Type on parameters. In the emitted Luau, every local already uses name: Type.
Protected calls. player:Kick() is Luau-style : and a pcall. Prefer . when the call should throw (player.Kick()). Use : when a missing child, a bad argument, or report must not stop the listener.
Range-for uses in (or : in a different position): for (T x in list).
Bare Table:Key without () still emits Table.Key (old table-key spelling). New code uses .: DataService.Server.
Example
Section titled “Example”age: int = 10;Instance child = workspace:FindFirstChild("Missing");guard (child != null) else { return;}Emits:
local age: number = 10local child: Instance = (function() local _ok, _r = pcall(function() return workspace:FindFirstChild("Missing") end) return if _ok then _r else nilend)()if not (child ~= nil) then returnend