I continue to get the error of unknown global ‘self’ and I don’t understand why since it is already defined. This error is occurring in the Upgrader.Init() function. I was doing a little bit of research on it, but the error others were getting was not the same as what I was looking for. Wanted to see if anyone knows why it says its unknown.
local Upgrader = {}
Upgrader.__index = Upgrader
function Upgrader.new(tycoon, instance)
local self = setmetatable({}, Upgrader)
self.Instance = instance
return self
end
function Upgrader.Init()
self.Instance.Detector.Touched:Connect(function(...)
self:OnTouch(...)
end)
end
function Upgrader:OnTouch(hit)
local worth = hit:GetAttribute("Worth")
if worth then
hit:SetAttribute("Worth", worth * self.Instance:GetAttribute("Multiplier"))
end
end
return Upgrader
The Error
Not sure what I am missing, but thank you to anyone who is willing to help!