You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I am attempting to make an OOP data module.
- What is the issue? Include screenshots / videos if possible!
I want to access the data object of a certain player without making a whole new one each time I access it from outside the player added script.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried returing self but cant find anything that helps me out with this issue roblox.
module
function StatsManager.new(player)
local self = {}
setmetatable(self, StatsManager)
self.Key = "hello"
return self
end
function StatsManager:GetManager(player)
return self
end
server script
local StatsManger = require(script.Parent.StatsManager)
game.Players.PlayerAdded:Connect(function(player)
local PlayerStatManager = StatsManger.new(player)
local Manager = StatsManger:GetManager(player)
print(Manager.Key)
end)