Skip to content

Types

CL++ is statically typed. clpp emits Luau with the same contracts. A type is what a value is allowed to be, and what you may do with it.

CL++LuauUse for
int, float, doublenumbercounts, damage, alpha
boolbooleanflags
stringstringnames, paths
void(no return)procedures
autoinferredwhen new or GetService makes the type obvious
Player, Folder, …Player, FolderInstances (class names, never Player*)
LuaArray<int> / array<T> / vector<T>{number}arrays (GetPlayers, inventory)
optional<T>T?missing values (prefer null on Instances)
Vector3, CFrame, UDim2samedatatypes
int coins = 10;
bool loaded = false;
Folder folder = new Folder(player);
local coins: number = 10
local loaded: boolean = false
local folder: Folder = Instance.new("Folder")
folder.Parent = player

Write Player player, not Player*. There is no ->, no address-of, no pointer arithmetic. Properties and instance methods use ..

player.Name = "Kartz";
player.FindFirstChild("leaderstats");
player.Name = "Kartz"
player:FindFirstChild("leaderstats")

Lifetime is Roblox’s: parented Instances live until Destroy or until a Sweep cleans them.

null is nil. Always test before using a FindFirstChild result:

auto stats = player.FindFirstChild("leaderstats");
if (stats == null) {
return;
}

Typos, wrong arguments, and nil indexing are the majority of live-game bugs. --!strict plus CL++ types catch them in the editor. If a function takes Player, do not pass a string. If a value is const int, do not assign to it later.

Next: const and immutability.