attempt to concatenate a nil value
❌ Error
attempt to concatenate a nil value (field 'xyz')
📍 Context
Occurs when you try to join strings with ..
but one of the variables is nil
. Typical cases:
- Concatenating player names or database values that are missing.
- Combining optional strings without checking.
✅ Solution
- Convert nil to empty string before concatenation:
local fullName = (firstName or '') .. ' ' .. (lastName or '')
- Check database results or player data before using them.
ℹ️ Additional Information
- Wrap all string operations with nil-safe defaults.