Hello,
I have created a module script to handle assigning players to a table based on team. I have required the module in my server script but am having trouble accessing the team tables from the module script. When i try to access the module script tables from the server script they return nil.
ModuleScript:
local PlayerManager = {}
local Players = game:GetService("Players")
local assignX = false
teamX = {}
teamO = {}
local function assignTeams(player)
if not assignX then
table.insert(teamO, player.Name)
assignX = true
else
table.insert(teamX, player.Name)
assignX = false
end
print("Team O: ".. table.concat(teamO, ","))
print("Team X: ".. table.concat(teamX, ","))
end
Players.PlayerAdded:Connect(assignTeams)
return PlayerManager
ServerScript:
local PlayerManager = require(Modules.PlayerManager)
I’ve tried several syntax with no success.
Ex.
PlayerManager.teamX
PlayerManager[teamX]
playerManager["teamX"]
What am i missing here?