attempt to perform arithmetic
A script tried to do maths with a value that was empty — very often a money or item amount that was never set.
Do this first
Check the player's row in the database for empty values in the column the message names.
What it means
+, -, *, /, % or ^ was applied to something that is not a number. The message names it: attempt to perform arithmetic on a nil value (field 'amount').
Lua coerces numeric strings in arithmetic ("5" + 1 is 6), so a string rarely triggers this. Nil almost always does.
What causes it
Ordered by how often it is the answer.
- 1
A missing table field
Config.Prices[item] * countwhere that item has no price entry. - 2
A database column that is NULL
NULL comes back as nil, not 0. A player row whose
bankwas never initialised breaks every balance calculation that touches it. - 3
A value the client was supposed to send and did not
An event handler doing
amount * priceon a payload the client omitted. - 4
Accumulating into an uninitialised variable
total = total + xwheretotalwas declared but never given a starting value.
How to tell which one is yours
Print the operand named in the message. If it came from the database, check the column for NULLs:
SELECT COUNT(*) FROM users WHERE bank IS NULL;
Where to look
The named line, then the source of that operand.
How to fix it
Default when reading, not when using:
local price = Config.Prices[item] or 0 local total = price * (count or 1)
For the database, make the problem impossible to repeat:
ALTER TABLE users MODIFY bank INT NOT NULL DEFAULT 0;
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