Metatable help (again)

Q1:
What is self?

Q2:
What is self's value in this case?

local base = {}
base.__index = base

base.Number = 5

function base:New()
	local t = setmetatable({}, self)
	t.__index = t
	
	return t
end

return base
local base = script.Parent.Base

local child = require(base):New()


return child

Is it the base table, the child variable or something else?

self is a keyword used to describe the corresponding object in object oriented programming. When used in a method, it refers to the object in which the method is being called on.

Self used int the first script would throw an error because self is not defined.

local something = {}
something.__index = something;

function something.new() -- Self is not defined in constructor functions.
    local self = setmetatable({}, something};
    self.somethingElse = 3123;
    return self;
end

function something:printSomethingElse() --Self would be defined here since it's a method of "something"
    print(self.somethingElse);
end

local somethingObject = something.new();
somethingobject:printSomethingElse(); --> 3123

Object oriented programming can be a little hard to understand for beginners, so I recommend reading up on it.

I use self to return functions when a modulescript function is called

In simple terms its just the table that has been indexed.

Some rules to it though.

Only is defined with functions that are indexed with : not . or []

local tbl = {}

tbl.thing = 'thing'

function tbl:DoSomething()
  print(self.thing) -- 'thing'
  self.thing = 'lol'
end

function tbl.DoAnother()
  print(self) -- nil
end

tbl:DoSomething()
print(tbl.thing) -- 'lol'