Is my Data Module any good?


#1

I made the this thing hoping to store data within a ModuleScript, any potential improvements?

local Loader = require(script.Parent.Parent.ModuleLoader)

local DataFunctions = Loader:Load("DataFunctions")

local Data = Loader:Load("DefaultData")

local Default = Data.DefaultData

local Module = {}

local Metatable = {}

local Prototype = Default

Metatable.__index = Prototype;

function Module.new(Player)
    Module[Player.Name] = {}

    local NewIndex = Module[Player.Name]

    local self = setmetatable({}, NewIndex)
    return self
end

function Metatable.Initialize(self, Player)

    local Key = "id_" .. Player.userId

    if not Data.DataStore:GetAsync(Key) then

        Save(Key, Default)

        self = Default

    else

        local Data = Load(Key)

        self = Data

    end

    return self

end

Module.Metatable = Metatable;

return Module;

#2

I think your code would be better if you indented your code inside your functions


#3

This is important. I can’t read your code at all because it’s not indented.


#4

It was indented, when i pasted it broke.

Also, I just fixed.