First steps, lesson 5
Strings
Goal: Build messages from text and values.
about 5 min4 practice exercises
A string is text: a name, a message, a label. Write it in double quotes.
Join strings with .. (two dots):
local playerName = "Liam"
local coins = 12
print("Welcome, " .. playerName)
print(playerName .. " has " .. coins .. " coins")
Joining does not add spaces for you. Put them inside the quotes, as in " has ".
Luau has a cleaner way for longer messages, called string interpolation. Use backticks and put values in curly brackets:
print(`{playerName} has {coins} coins`)
A number in quotes is a string, not a number: "5" == 5 is false. Keep numbers as numbers and only turn them into text when you show them.
# gives the length of a string: #"coin" is 4.
Sources
Checked against Roblox's documentation on . The lesson is in our own words; these pages are the source of truth.