Metatable can't find an instance ; ;

 `local Booster = {}

Booster.__index = Booster`

function Booster.new(Type)

local self = {}
setmetatable(self, Booster)

self.booster = TMPFrame:Clone()
print(self.booster)
print(typeof(self.booster))
Booster:SetFrame(Type)

end

function Booster:SetFrame(Type)
if Type == "AutoSell" and NotClone == true then
	NotClone = true
	print(self.booster)
	self.booster.Parent = script.Parent
	self.booster.AutoText.Visible = true
	self.booster.AUTOSELL.Visible = true
elseif Type == "AutoSoul" and NotClone == true then
	print("AutoSoul")
	NotClone = true
	self.booster.Parent = script.Parent
	self.booster.AutoText.Visible = true
	self.booster.AUTOSOUL.Visible = true
end

end

Why are you doing Booster:SetFrame(Type) and not self:SetFrame(Type) in the constructor? You want to be setting the booster property of self, not the Booster table itself. Take this as an example.

local obj = {}
obj.__index = obj;
obj.x = 50;

function obj.new()
	local t = setmetatable({}, obj);
	t.x = 10;
	print(t:Test("x"), obj:Test("x"));
end

function obj:Test(x)
	return self[x];
end

obj.new();

Unless you had a pseudo-static member always use the instance of the object and not the object itself.

2 Likes

Wow!!!
Oh, yeah!
Thank you so much for answering so quickly