Luacrash
attempt to perform arithmetic on a nil value
Also seen as: arithmetic on a nil value attempt to perform arithmetic (field) nil arithmetic Lua
What causes it
Your code tried to do math (+, -, *, /) with a value that's nil. Usually a Config value, a table field, or a returned value that doesn't exist. The parentheses name what's nil.
How to fix it
Find the nil value named in the error and ensure it has a number before the math runs.
- Read the variable/field in parentheses — that's what's nil.
- If it's a Config value, confirm it's defined and the config loads before this code.
- If it's a returned value, check the function actually returned a number.
- Add a default:
local n = value or 0before the arithmetic.
Related errors
Related guides
Still stuck? We can help.
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.