Lua:为什么我的函数调用会有一个空错误?

在我的代码中,我有一个脚本和两个ModuleScripts。 在其中一个ModuleScripts中,我创建了一个名为storageArray的表。

local module2 = {}

module2.storageArray = {}

return module2

在另一个ModuleScript中,我创建了一个名为printInfo的函数。

local module2 = require(game.ServerScriptService:WaitForChild("storageModule")) -- 调用storageModule ModuleScript

----变量----
functionArray = {} -- 全局变量

----游戏函数----
functionArray = {
    printInfo = function(info)
        print(info)
    end
}
return functionArray

我遇到的错误是,当我调用函数printStorageArray时,我会得到错误"attempt to index nil with 'printInfo'"。 这是我在常规脚本中的函数调用:

----Game Events----
local module = require(game.ServerScriptService:WaitForChild("Functions")) -- 调用函数ModuleScript
local module2 = require(game.ServerScriptService:WaitForChild("storageModule")) -- 调用storageModule ModuleScript

game.Players.PlayerAdded:Connect(function(player1) --获取加入游戏的用户的用户名/用户ID
    local name = player1.Name
    print(name .. "已经进入游戏!") -- 将userID添加到storageArray(storageArray保存所有加入游戏的用户)
    local ID = player1.UserId           -- 每次有人加入服务器时激活
    print(ID)
    local storageArray = module.storageArray
    table.insert(module2.storageArray, ID)
    print"ID's: " .. module2.storageArray [1]..", "-- **测试使用2个人
    local playerName = player1.Name
endprint"TEST"module.functionArray.printInfo(module2.storageArray)-- ERROR OCCURS HERE

我不确定我在这里做错了什么。感谢你的帮助!

点赞