attempt to perform arithmetic on a nil value
❌ Error
attempt to perform arithmetic on a nil value (field 'xyz')
📍 Context
Happens when trying to add, subtract, multiply, or divide a variable that is nil
. Common with player money, inventory counts, or job data.
✅ Solution
- Initialize variables before arithmetic operations:
local value = myValue or 0
- Ensure that callbacks or database queries return valid numbers.
ℹ️ Additional Information
- Can occur both clientside and serverside.
- Useful to enforce default values for all numeric fields.