Hello, looks like there’s no post about this, but i’ve been making a script about a makable Hamburguer, but there’s a trouble, I feel, not deleting Metatable, makes me feel uncomfortable, having a lot of information over there, might be laggy, anyway if it’s not laggy, how can I remove a metatable once what I wanted to do was finished?
Code:
local Burguers = {}
Burguers.__index = Burguers
function Burguers.NewBurguer(plr)
return setmetatable({burguer = script.Model:Clone(), currentstep = 0, player = plr}, Burguers)
end
function Burguers:SetCFrame(CFramee)
self.burguer:SetPrimaryPartCFrame(CFramee)
end
function Burguers:SetAnchored(val)
self.burguer.Primary.Anchored = val
end
function Burguers:SetParent(Parent)
self.burguer.Parent = Parent
end
function Burguers:GiveMeat()
self.burguer.Burguer.Transparency = 0
end
function Burguers:GiveCheese()
self.burguer.Cheese.Transparency = 0
end
function Burguers:Finish()
self.burguer.UpBreade.Transparency = 0
self.currentstep = 0
wait(2)
self.player.leaderstats.Wallet.Value = self.player.leaderstats.Wallet.Value + 10
game:GetService("Debris"):AddItem(self.burguer, 5)
end
function Burguers:GiveBread(Value)
if Value == "1" then
self.burguer.DownBread.Transparency = 0
end
if Value == "2" then
self.burguer.UpBreade.Transparency = 0
end
end
function Burguers:GiveFunction()
local ClickDetector = Instance.new("ClickDetector", self.burguer)
ClickDetector.MouseClick:Connect(function(Player)
print("Clicked")
self.currentstep = self.currentstep + 1
local step = "Step"..self.currentstep
print(self.player.Name)
print(self.currentstep)
if step == "Step1" then
print("Step1")
print(self.currentstep)
self:GiveBread("1")
elseif step == "Step2" then
print("Step2")
self:GiveMeat()
elseif step == "Step3" then
self:GiveCheese()
elseif step == "Step0" then
return
elseif step == "Step4" then
self:Finish()
end
end)
end
return Burguers