attempt to compare
A script tried to compare two things that cannot be compared, usually a number against something that is missing or is text.
Do this first
If it happened after a command, the values typed into that command are the likely cause.
What it means
<, >, <= or >= was used between values Lua cannot order: attempt to compare nil with number, attempt to compare string with number, attempt to compare two table values.
== never produces this. Only the four ordering operators do, which narrows the search on the reported line immediately.
What causes it
Ordered by how often it is the answer.
- 1
A nil on one side
if playerMoney > pricewhere the lookup returned nothing. Same underlying problem as an index-nil, one line later. - 2
A number that arrived as a string
Config values written as
"100", JSON payloads, and command arguments. FiveM command arguments are ALWAYS strings, including in/givemoney 1 5000. - 3
Comparing a vector to a number
#(a - b) > 5.0is correct.(a - b) > 5.0compares vectors. - 4
A database column read straight through
oxmysql returns what MySQL gives it, and DECIMAL columns can arrive as strings.
How to tell which one is yours
print(type(left), type(right))
The message already names the two types, so you are mostly confirming which variable holds which.
Where to look
The named line. If the value came from a command, look at the argument parsing; if from the database, look at the column type.
How to fix it
Convert once, at the boundary:
RegisterCommand('givemoney', function(source, args)
local target = tonumber(args[1])
local amount = tonumber(args[2])
if not target or not amount or amount <= 0 then return end
-- safe from here
end)For distance, use the length operator:
if #(GetEntityCoords(ped) - target) > 5.0 then return end
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