Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is sessionData[player] suddenly nil?

Asked by 6 years ago

So I have a Module Script that keeps player stats in a table (in this case, sessionData), like this:

local module = {}
local sessionData = {}

function module.setup(player)
    sessionData[player] = {
        money = 100
    }
    print(sessionData[player].money)
end

function module.test(player)
    return sessionData[player].money
end

return module

Now, say the module.setup(player) method is called whenever a player joins; in the method, the print statement prints '100', but when the module.test(player) method is called, it says it's nil.

Any ideas?

Answer this question