attempt to concatenate a nil value
A script tried to build a message out of a value that was missing, usually a player name or a config setting you left blank.
Do this first
Check the config file of that script for a setting that was never filled in.
What it means
The .. operator was used with something that is neither a string nor a number. The message names it: attempt to concatenate a nil value (local 'name').
Lua concatenates numbers happily, so this is nearly always nil, and nearly always inside a string being built for a print, a notification, a chat message or a query.
What causes it
Ordered by how often it is the answer.
- 1
A missing table field in a message
'Welcome ' .. player.namewhere the player object has noname, or the whole object is nil. Building the message is where the missing data first bites. - 2
A function that returned nothing
GetPlayerName(src)returns nil for a player who has already left, and the result goes straight into a log line. - 3
A config value that was never set
Config.Webhook .. '?wait=true'with the webhook left empty in a config the user never filled in. - 4
Building SQL by concatenation
Which is also an injection hole, so this error is doing you a favour by drawing attention to it.
How to tell which one is yours
Wrap the operand in tostring() temporarily — the error goes away and the message prints nil exactly where the missing value was, which tells you which one it is without any guessing.
Where to look
The named line. Read the whole expression: a long concatenation can have five operands and only one of them is nil.
How to fix it
Default the value, or use string.format, which tolerates nil in %s:
local name = GetPlayerName(src) or 'unknown'
print(('player %s bought %s'):format(name, item or 'nothing'))For SQL, use placeholders instead of concatenation:
MySQL.query('SELECT * FROM users WHERE identifier = ?', { identifier })Still stuck on your own code?
This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.
bug_reportOpen Server Fixer