OOP Module Problem

Hi, so as of recently I’ve started learning Lua OOP and I’m particularly stuck at this part and I don’t know whereabouts I went wrong.

-- This is the module script code
local Module = {}
Module.__Index = Module

function Module.new(Player,EquipState,TypeName,Character)
	local Object = {}
	setmetatable(Object,Module)
	Object.Player = Player
	Object.EquipState = EquipState
	Object.TypeName = TypeName
	Object.Character = Character
	return Object
end

function Module:printself()
	print(self.Player)
end

return Module
------------------------------------------
--This is the local script code
local Player = game.Players.LocalPlayer
local Character =script.Parent

local OBJ = require(game.ReplicatedStorage.ModuleScript)

local Test = OBJ.new(Player,false,"Rod",Character)
Test:printself()

Screenshot of error:

__index should not be capitalized

3 Likes

Really silly of me thank you so much!

1 Like