lloyAlloy on GitHub
remote
Docs

remote

Updated
remote Name(params) from client
remote function Name(params): R from client

A typed channel between server and client. The compiler reads a layout off the parameters, and the runtime packs each fire into one buffer: a number at the width its attribute names, @u8 to @f32, or 64 bits without one; a boolean as a byte; a string with its length; an optional parameter with a presence byte. A struct opens to its fields, with the widths its fields declare, and the reader restores its metatable; a record type, { x: number, y: number }, opens the same way; T[], { T }, and Array<T> pack a count and each item. An enum crosses too: a unit enum as the variant's name, which the reader checks, and a payload enum beside the buffer, where the reader checks the tag and restores the metatable, so the variant's methods and == work on arrival. What none of that covers, a Player, an Instance, a map, crosses beside the buffer as it is, and a remote whose parameters are all such stays unpacked. The handler sees the arguments as declared, defaults filled.

The object: fire(...) sends (to the server from a client; to one player, the first argument, from the server), fire_all(...) and fire_except(player, ...) send from the server to every client or all but one, call(...) asks a remote function and yields Future<R>, on(handler) and once(handler) receive (the connection comes back), wait() yields a Future of the next event, and on_ratelimited(handler) hears a sender that @ratelimit refused. spec holds the declaration, and instance the Roblox object behind it, typed by the kind: RemoteEvent?, UnreliableRemoteEvent? under @unreliable, or RemoteFunction? for a remote function.

from names the side that starts the exchange: the side that fires an event, or the side that asks a remote function. A function that the client asks and the server answers is from client.

The declaration types the object. The side that fires passes the parameters, and a default makes one optional; a handler gets them filled, and a server handler gets the sender first: BuySaber.on(function(sender, id) ... end) types sender: Player and id: string. call on a remote function yields Future<R>.

The word is also free as a name. remote declares only before a name or function on the same line, so local remote = folder.Hit and t.remote read the Luau way.