I need some help with error code esx_policejob/client/main.lua:340: bad argument #1 to 'for iterator' (table expected, got nil)

I need some help


Hey :slightly_smiling_face:
We cannot see the lines number on your screenshot, so from an outside point of view we can only guess wich of the two loops in the screenshot is having an issue.

My guess would be the second one : ‘ipairs(Config.CustomPeds[grade])’. The issue would be that the ‘grade’ which the script tried to access form the ‘Config.CustomPeds’ doesn’t exist, so it returned ‘nil’ and tried to iterate on it and you got an error. If i’m correct check the config you should have at least an empty lua table set for each possible ‘grade’ :

You can do some testing to be sure, you add a ‘print(grade)’ just above the Loop, you recreate the error in game and see if the ‘grade’ that got printed in the console has a entry in the config (if not it confirms what I said above).

2 Likes

This! :point_up_2:
Well answered, @thibaultD
You beat me to it.

1 Like

where do i find this on my QBcore configs?

image_2024-11-23_030428632
Screenshot 2024-11-23 030319

anyone know how to fix

)