I am making a custom BackpackGui instead of the default roblox one using OOP. Can you review my code to see if this is how you do a constructor in OOP?
ModuleScript:
local BackpackGui = {}
BackpackGui.__index = BackpackGui
--Static fields
BackpackGui.equipped = 0.2
BackpackGui.unequipped = 0.7
BackpackGui.iconSize = {x = 60, y = 60}
BackpackGui.iconBorder = {x = 15, y = 5}
--constructor
function BackpackGui.new(player)
local O = {}
--Instance fields
O.inputKeys = {["One"] = {txt = "1"},["Two"] = {txt = "2"},["Three"] = {txt = "3"},}
O.inputOrder = {O.inputKeys["One"],O.inputKeys["Two"],O.inputKeys["Three"],}
O.toShow = #O.inputOrder
BackpackGui.totalX = (O.toShow*BackpackGui.iconSize.x)+((O.toShow+1)*BackpackGui.iconBorder.x)
BackpackGui.totalY = BackpackGui.iconSize.y+(2*BackpackGui.iconBorder.y)
--Now creates a a container for all the slots
O.container = Instance.new("Frame")
O.container.Position = UDim2.new(0.5, -(BackpackGui.totalX/2), 1, -(BackpackGui.totalY+(BackpackGui.iconBorder.y*2)))
O.container.Size = UDim2.new(0, BackpackGui.totalX, 0, BackpackGui.totalY)
O.container.Parent = player.PlayerGui
--now creates the slots and place them inside the container
for i = 1, #O.inputOrder do
local value = O.inputOrder[i]
O.template = Instance.new("Frame")
O.template.Name = value["txt"]
O.Size = UDim2.new(0, BackpackGui.iconSize.x, 0, BackpackGui.iconSize.y)
O.Position = UDim2.new(0, (i-1)*(BackpackGui.iconSize.x)+(BackpackGui.iconBorder.x*i), 0, BackpackGui.iconBorder.y)
O.template.Parent = player.PlayerGui.container
O.imageLabel = Instance.new("ImageLabel")
O.imageLabel.Size = UDim2(1,0,1,0)
O.imageLabel.Position = UDim2(0,0,0,0)
O.imageLabel.Parent = player.PlayerGui.container
O.textLabel = Instance.new("TextLabel")
O.textLabel.Size = UDim2(0.4, 0, 0.4, 0)
O.textLabel.Position = UDim2(0.2 ,0, 0.6, 0)
O.textLabel.Parent = player.PlayerGui.container
end
setmetatable(O, BackpackGui)
end