When a player joins a game I want to add a table containing their information (inventory, variables etc.) to a global table that I can then index by using the player's name. For example, if I want to access a player's coins I could do:
_G.Players.[player name here].coins
But I can't quite figure out how to add a table to a global table using the name of the player. If anyone could help it would be very appreciated.
game.Players.PlayerAdded:connect(function(plr) _G.Players[plr.Name]["Coins"] = 0 end) game.Players.PlayerRemoving:connect(function(plr) _G.Players[plr.Name] = nil end)
I don't for sure but maybe something like this:
local Table1 = {1,2,"Hello","This is me table lol"} local Table2 = {4,6,7,4,"No this is me new table xD"} local Tables = {Table1,Table2}
Does that work?