Hello, as said in the title I am attempting to index a value of “self” below, and the value is returning nil, I’m not entirely sure why and can’t seem to find a solution.
Code:
local aTable = {}
local metatable = {__index = aTable}
function aTable.initialize(MinSpeed, MaxSpeed, AccelIncrement)
local self = {}
setmetatable(self, metatable)
-- Values --
self.SetValues = {}
self.SetValues.MIN_SPEED = MinSpeed
self.SetValues.MAX_SPEED = MaxSpeed
self.SetValues.ACCEL_INCREMENT = AccelIncrement
self.SetValues.GRAV = workspace.Gravity
--
print(self)
return self
end
--
function aTable:start(target)
print(self.SetValues) -- Prints "nil"
end
Might have something to do with this line, then?
Try replacing it with aTable._index = aTable and do setmetatable(self, aTable) instead of setmetatable(self, metatable)