attempt to compare nil with number
❌ Error
attempt to compare nil with number
📍 Context
Occurs when a variable is nil
but you try to compare it with a number using >
, <
, >=
, <=
. Often happens when player data is missing or uninitialized.
✅ Solution
- Ensure the variable is initialized before comparison:
if myValue ~= nil and myValue > 0 then ... end
- Validate data from database queries or callbacks before using it.
ℹ️ Additional Information
- Wrap all numeric operations with nil checks to prevent runtime errors.