I have a ModuleScript. For some reason if I change the table it works fine, but when I then print it it doesn’t work? This is in Server Script Service, all code is run server sided.
Here is a code example
local mytable = {}
function AddPlayerToTable(player)
mytable[player] = "HI!"
print(mytable) -- prints the table
end
local Module = {}
function Module.ChangeInfo(Player) -- If i call this after the AddPlayer Function
print(mytable) -- prints blank table
end
function Module:Init()
Players.PlayerAdded:Connect(AddPlayerToTable)
end
return Module
also, assuming that’s the whole module, it should error because you didnt define Players
if that’s not the full module, please also add any other code that touches myTable
I call init in a script in Server Script Service as I have a few scripts requiring an Init. I did this to avoid memory leaks. Module.ChangeInfo for the time being I call out of the console on the server part of play test. And Players is defined I just didn’t include it.