THE ORB
Starting the studio

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.

groupsMoney or items misbehavecodeNeeds a developer

Do this first

Check the player's row in the database for empty values in the column the message names.

bug_reportPaste your whole console instead

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. 1

    A missing table field

    Config.Prices[item] * count where that item has no price entry.

  2. 2

    A database column that is NULL

    NULL comes back as nil, not 0. A player row whose bank was never initialised breaks every balance calculation that touches it.

  3. 3

    A value the client was supposed to send and did not

    An event handler doing amount * price on a payload the client omitted.

  4. 4

    Accumulating into an uninitialised variable

    total = total + x where total was 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

Errors that travel with this one