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

Why does this model of Table Nesting & Module Scripts not work?

Asked by 4 years ago

New to Lua and I can't for the life of me figure out tables.

local Players = game:GetService("Players")
local MasterIngamePlayerTable = require(script.Parent.MasterIngamePlayerTable)
local PlayerState = require(script.Parent.PlayerState)

Players.PlayerAdded:Connect(function(player)

    MasterIngamePlayerTable[player.Name] = {}
    print(MasterIngamePlayerTable[player.Name])
    MasterIngamePlayerTable[player.Name]["state"] = PlayerState
    print(game.ServerScriptService.MasterIngamePlayerTable[player.Name]["state"].test)

end)

I get the error [player.Name] is not a valid member of ModuleScript. Thanks for any help!

1 answer

Log in to vote
0
Answered by 4 years ago

Might be jumping to conclusions here, but the print statement was in the same environment so it was referencing the original tableless state of the module? It worked when I debugged in another script, so I'll just move on with my life.

Ad

Answer this question