Your first script
Create hello.server.clpp. The .server tag means Rojo will treat the output as a Script.
#include <clpp/roblox.clh>
struct HelloServer { void Greet(Player player);};
void HelloServer::Greet(Player player) { post("Player name: " .: player.Name);}
void init() { HelloServer hello; Players players = GetService<Players>();
for (Player player in players.GetPlayers()) { hello.Greet(player); }
players.PlayerAdded~>Connect(func (Player playerEntered) { hello.Greet(playerEntered); });}Line by line
Section titled “Line by line”#include <clpp/roblox.clh>— IntelliSense for engine types. No Luau is emitted for this header.struct HelloServer+void HelloServer::Greet— define methods with::. Call them with.(hello.Greet(player)).player.Name— property (dot)."Player name: " .: player.Name— concatenation (.:→ Luau..).void init()— runs at the end of Scripts and LocalScripts.GetService<Players>()— typed service lookup.for (Player player in players.GetPlayers())— range-for.inis the collection.players.PlayerAdded~>Connect—.reads the signal,~>gives Connect to Janitor. Manual (no janitor) is::Connect.func (Player playerEntered) { ... }— anonymous callback. Luau closures still see outer locals. There is no C++ capture list[].
Compile:
clpp compile hello.server.clppYou get Luau with function HelloServer:Greet, game:GetService("Players"), and an init() call at the bottom.
Next: Mental model.