Skip to content

Variables and scope

int n = 0; // local number
age: int = 10; // same, postfix type
const int MAX = 10; // Luau const
observable int coins = 100; // IntValue; assign to fire Changed
signal<Player, int> OnPay; // BindableEvent wrapper
auto players = GetService<Players>();
  • File-level declarations → file local / const.
  • Inside a function → from that line to the end of the block. Nested { } may shadow.
  • Inside Class::Method@this / this is self. @field and bare field names become self.field. Parameters shadow fields.

post, warn, report, game, workspace, task, library types, Instance classes, datatypes.

Leaving a { } block does not Destroy Instances. Use Janitor, ~>Connect, or an explicit .Destroy().

auto [ok, result] = pcall(func () {
return 1;
});

Emits local ok, result = pcall(...).

Next: Functions and callbacks.