I’m trying to use a module’s functions on a server script, however I get the error "attempt to call a nil value " on this specific line:
NPC_Utility.insertCharacter(character)
Server
local ServerScriptService = game:GetService("ServerScriptService")
-- module scripts
local NPC_Utility = require(ServerScriptService.NPC.StalkerScripts:WaitForChild("StalkerController"))
function UpdateCharacterList(character)
NPC_Utility.InsertCharacter(character)
print(NPC_Utility.GetCharacterTable())
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
UpdateCharacterList(character)
end)
end)
Module
local utility = {
CHARACTER_LIST = {},
}
function utility.InsertCharacter(character)
table.insert(utility.CHARACTER_LIST, character)
end
function utility.RemoveCharacter(character)
local index = table.find(utility.CHARACTER_LIST, character)
table.remove(utility.CHARACTER_LIST, index)
end
function utility.GetCharacterTable()
return utility.CHARACTER_LIST
end
return utility