Is there any way to improve my Class Module? Just wondering what I can do to make it more efficient. Also, don’t mind CFramework on the top. Just my custom framework.
Another thing to mention, CharacterAutoReloads will be off.
local CFramework = require(game:GetService("ReplicatedStorage"):WaitForChild("Shared"):WaitForChild("CFramework"))
local PlayerClass = CFramework:New({}, "Class", "PlayerClass")
PlayerClass.__index = PlayerClass
function PlayerClass.new(Player, State, Level, Inventory)
--[[
self.Name is self Explantory
self.PlayerReference is a Reference to the Player, Incase I create future methods
Two Different Possible Status: "IN_GAME" and "DEAD"
self.Level is basically a stat
self.Inventory is a table of the user's Inventory.
]]--
local self = setmetatable({}, PlayerClass)
self.Name = Player.Name
self.PlayerReference = Player
self.State = State or nil
self.Level = Level.L or 1
self.Inventory = Inventory
return self
end
function PlayerClass:UpdateStatus(Status)
-- Must be Called on to occur, doesn't happen randomly.
self.State = Status
return self.State
end
function PlayerClass:UpdateLevel()
-- Occurs Every Minute via While True Do
if self.Level.XPRequired <= self.Level.CurrentXP then
self.Level.L += 1
end
if self.Level.L >= 100 then
self.Level.Prestige += 1
self.Level.L = 1
end
end
function PlayerClass:IsDead()
wait(1)
self.PlayerReference:LoadCharacter()
end
function PlayerClass:UnboxedItem(item)
for i, v in pairs(self.Inventory) do
if item == v then
v += 1
elseif item ~= v then
table.insert(self.Inventory, #self.Inventory+1, item)
end
end
end
return PlayerClass