Fivem bad argument #1 to 'pairs' error


Environment questions

GTA V version: 6337558
Up to date: 19 march 2021
Legit or Pirate copy: Legit
Purchased where - Steam/Rockstar Launcher/Epic: Steam
Windows version: 20H2
Did you try to delete content_index.xml and try again?
System specifications:
AMD Ryzen 7 2700X
RX 580
16gb of ram DDR4 2666mhz
CitizenFX crash zip file (‘Save information’ on a crash):
logs/CitizenFX_log files:
CitizenFX_log_2021-06-11T211945.log (101.0 KB)

.dmp files/report IDs:

Important parts

What is the issue you’re having?
I create a server with this script GitHub - Dislaik/zombieoutbreak: Zombie Survival RPG for FiveM!. All my friends can join but when I try to enter I have this error and an infinite awating scritp:

[ 29188] [ GTAProcess] MainThrd/ Error loading script Root/Shared/Main.lua in resource zombieoutbreak: @zombieoutbreak/Root/Shared/Main.lua:12: bad argument #1 to ‘pairs’ (table expected, got nil)
[ 29188] [ GTAProcess] MainThrd/ stack traceback:
[ 29188] [ GTAProcess] MainThrd/ [C]: in function ‘pairs’
[ 29188] [ GTAProcess] MainThrd/ @zombieoutbreak/Root/Shared/Main.lua:12: in main chunk
[ 29188] [ GTAProcess] MainThrd/ Failed to load script Root/Shared/Main.lua.

What are you trying to do?
I try to enter in my server

What have you tried already to fix the issue?
I tru to reinstall fivem, delete server cache, detele client cache

Error screenshot (if any):

What did you do to get this issue?
nothing

What server did you get this issue on? Be specific and name some, ‘all of them’ by itself isn’t useful!
In my private server with latest server version


Hello, this is a friendly reminder because this is your first time creating a topic (or it has been a while since your last topic) in this category.

Please note that most of the support is provided by the Cfx.re community on a voluntary basis. We ask you to be patient; there is no guarantee we have a solution to your problem(s). To avoid unnecessary/duplicate topics, please browse the forums before creating a topic.

To improve your chances of your issue(s) being solved, please provide as much information as possible about the issue(s) you are having. Also —whenever possible— please use the template given to you when creating a topic.

Thanks for keeping these forums tidy!
:mascot:

Hello! First of all, I tru to reinstall fivem, delete server cache, detele client cache doing that sort of things actually NEVER fix any issue, FiveM has a self-repair system.

Talking about your issue, could you please send me the file that is generating that error (Root/Shared/Main.lua:12)?

1 Like

You are not alone TheKap Mine just started this recently and wiping everything uninstalling deleting cache server etc and doing it fresh this error still there…

There a individual on discord that is recreating this error and trying to do a work around i guess. Either way its a Fivem Client issue … after there recent update this appeared… with Json Encoding and Decoding… when i got done with the vitals i created… and got working i decided sweet time for bed got on the next day to do some other work on more features… and i couldn’t spawn.

Root = {}

Modules = {}

local Categories = {"Core", "Base", "User"}

local Fxmanifest = {"Shared", "Client", "Server"}

for i in pairs(Categories) do

    local File = GetDataFile("Modules/" .. Categories[i] .. "/Modules.json")

    local JSONData = json.decode(File)

    table.insert(Modules, Categories[i])

    Modules[i] = {}

    for j in pairs(JSONData) do
        --line 12 is this print
        print("^5[^0DayZ^5] ^4[^0".. JSONData[j] .."^4]^2 Loaded") --Server Loaded Modules

        table.insert(Modules[i], JSONData[j])

        Modules[i][j] = {}

        Modules[i][j]["Path"] = "Modules/" .. Categories[i] .. "/" .. JSONData[j] .. "/"

        Modules[i][j]["Category"] = Categories[i]

        Modules[i][j]["Name"] = JSONData[j]

        Modules[i][j]["CodeSide"] = {}

        for k in pairs(Fxmanifest) do

            Modules[i][j]["CodeSide"][Fxmanifest[k]] = {}

            local EventsCode = GetDataFile("Modules/" .. Categories[i] .. "/" .. JSONData[j] .. "/".. Fxmanifest[k] .."/Events.lua")

            local MainCode = GetDataFile("Modules/" .. Categories[i] .. "/" .. JSONData[j] .. "/".. Fxmanifest[k] .."/Main.lua")

            Modules[i][j]["CodeSide"][Fxmanifest[k]]["Events"] = EventsCode

            Modules[i][j]["CodeSide"][Fxmanifest[k]]["Main"] = MainCode

        end

    end

end

LoadModules("Shared")

It happened to me after I updated fivem

Please test canary.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.