The Luau Upgrades
Lua is already a solid language, but Luau adds some quality-of-life features that make everyday coding a lot smoother. Here are two you'll find yourself using constantly.
Compound Assignment
In regular Lua, if you want to add something to a variable, you'd write:
local count = 0
count = count + 1Luau lets you shorten that with compound assignment operators:
local count = 0
count += 1 -- same as count = count + 1
count -= 1 -- same as count = count - 1
count *= 2 -- same as count = count * 2
count /= 2 -- same as count = count / 2
count //= 2 -- same as count = count // 2
count %= 2 -- same as count = count % 2
count ^= 2 -- same as count = count ^ 2It's a small change, but it makes code cleaner and easier to read — especially inside loops where you're updating values frequently.
String Interpolation
Normally, if you want to build a string from multiple values, you'd concatenate them using ..:
local name = "Luau"
local version = 5
print("Welcome to " .. name .. " version " .. version)It works, but it gets messy fast. String interpolation lets you embed values directly inside a string using backticks and {}:
local name = "Luau"
local version = 5
print(`Welcome to {name} version {version}`)Much cleaner. Anything inside {} gets evaluated and dropped right into the string. You can even put expressions in there:
local a = 10
local b = 3
print(`{a} + {b} = {a + b}`) -- 10 + 3 = 13Just keep in mind that string interpolation only works with backtick strings — it won't work with regular quotes.