Self printing nil

hello iam learing OOP , i wrote a script and its printing nil

local module = {}
module.__index = module
function module.Init(gui)
    --    assert(gui == "Instance","gui need to be a instance rip")

    local t = setmetatable({},module)
    t.TextBox = gui
    return t
function module:Check()
return module

help me ! Thanks

1 Like

Can we see the script that is calling module.Init()? You might be passing a nill value into the function.

Makes sure to run Check on your newly created object like so:

local module --require( somewhere)

local guiThing = module.Init("Hello")

guiThing:Check()-- has the "Hello"
module:Check()--Is nil

guiThing is the property table containing the properties and module is the function table containing the methods that are shared.