attempt to perform arithmetic (add) on string and numberin Roblox Luau: what it means and how to fix it
What it means
You used + to join text to something else. In Luau + only adds numbers. Joining text uses two dots.
Prefer to watch? Why + will not join text in Luau: use two dots (25 seconds, on YouTube).
The smallest script that triggers it
local score = 5
print("Score: " + score)
The fix
local score = 5
print("Score: " .. score)
The .. operator joins strings, and it turns numbers into text for you.
Common causes
- A habit from JavaScript or Python, where + joins strings.
- TextBox text that is empty or not a number, added to a number. Text such as "5" is converted for you; "" and "five" are not.
- A number stored as text, such as "10 coins", used in a calculation.
Practice this until it sticks
A Deep Dive on strings and concatenation: 5-minute lessons, each with a quiz. What you miss comes back in the next module. One Deep Dive a day is free. No card.