I wrote this Module that I know 100% is wrong since it doesn't work. I want to be able to apply the player_properties table to a new player object, but I am struggling to understand how that is going to work. I've looked at all the metatable/metamethod Wikis's on the front page of Google, but I am still confused on what is actually happening. What my end goal is - is to be able to call a function inside of players ( something like players.new() ) that will set a player object with the player_properties attached to it.
I would rather you not write the thing out for me, but tell me what sort of things have to occur to make what I'm trying to do possible.
local player_properties = {name = nil,
data = nil,
inventory = nil,
hotbar = nil,
getdata = function(plr) return plr.data end
}
local players = {}
local module = {}
module.addPlayer = function(player, data)
players[player] = {player, data}
setmetatable(players[player], player_properties)
end
return module
Also should mention that I'm not passing in a player object to player, passing in a String.

3 comments
Player is an abstract class. Why would you need to create a new player anyways?
Just for better organization and ease of use, and so I can store custom data such as the inventory or hotbar.
Also should mention that I'm not passing in a player object to player, passing in a String.