I used return grilltable at the end, forgot to copy it. Apologies. I can’t return grillfunctions because of my first table.
I’m noticing that in your grillfunctions.Submit function, you’re using self.Character
but self.Character is never declared within your module
Wouldn’t using : automatically claim that player is the first parameter, and player.Character afterwards?
then do this instead:
return grilltable, grillfunctions
And wherever you are requiring it, it is the second value so
local grilltable, grillfunctions = require("path")
No, using : will take the module itself as the first parameter not the player
I searched a solution to “Missing Method”, and this is what I could find.
to use such script would be the following:
local grillfunctions = {}
grillfunctions.__index = grillfunctions
Otherwise, I’ve never encountered such errors and wouldn’t know how to solve them without searching more about it.
Still the same issue. I used the metatable method you’ve mentioned.
local grilltable = {
FoodRequired = 5,
Cooked = 0,
FoodCount = 0,
DishValue = 0
}
local grillfunctions = {}
grillfunctions.__index = grillfunctions --added here
local Sizzle = script.Parent.Parent.Sizzle
function grillfunctions:FoodVisbility(x,y)
for i,v in ipairs(script.Parent.Parent.CookingProcess:GetChildren()) do
v.Transparency = x
if v:FindFirstChild("ParticleEmitter") ~= nil then
v.ParticleEmitter.Enabled = y
end
end
return
end
function grillfunctions:Submit()
while grilltable.FoodCount ~= grilltable.FoodRequired do
local foods = self.Character:FindFirstChild("Tray").Foods:GetChildren()
local v = foods[#foods]
if v ~= nil then
if v:FindFirstChildWhichIsA("Attachment") ~= nil then
local rarity = v:FindFirstChildWhichIsA("Attachment").Name
if rarity then
local value = game.ReplicatedStorage.ExtraCoin:FindFirstChild(rarity).Value
grilltable.DishValue += value
end
end
v:destroy()
else
break
end
grilltable.FoodCount += 1
task.wait()
return
end
end
function grillfunctions.Cook()
if grilltable.FoodCount == grilltable.FoodRequired then
grilltable.FoodCount = 0
Sizzle:Play()
return
end
end
return grilltable
I do recommend you research more on how modules and metatables work. The docs have many useful examples as to their functionality like so:
Script:
‘’'lua
if FoodPresent == false then
if CookingStatus == false then
if player.Character.Tray.Foods:GetChildren() ~= nil then
CookingFuncs:Submit(player)
script.Parent.Placeholder.SurfaceGui.TimeDisplay.Text = CookingFuncs.FoodCount…“/”…script.parent.FoodNeeded.Value
else
print(“You have no foods!”)
end
if #player.Character.Tray.Foods:GetChildren() == 0 then
Putdown:FireClient(player)
player.Character:FindFirstChild("Tray"):Destroy()
end
if CookingFuncs.FoodCount == CookingFuncs.FoodRequired then
CookingStatus = true
CookingFuncs.Cooked = CookingFuncs.FoodCount
CookingFuncs.FoodCount = 0
Sizzle:Play()
CookingFuncs:FoodVisbility(0,true)
local duration = tick()
repeat
script.Parent.Placeholder.SurfaceGui.TimeDisplay.Text = math.floor(CookingTime.Value - (tick() - duration))
task.wait()
until (tick() - duration) >= CookingTime.Value
CookingFuncs:FoodVisiblity(1,false)
Sizzle:Stop()
script.Parent.Placeholder.SurfaceGui.TimeDisplay.Text = CookingFuncs.FoodCount.."/"..script.parent.FoodNeeded.Value
local DishPicked = game.ReplicatedStorage.Recipe:FindFirstChild("DefaultDish")
local Dish = DishPicked:Clone()
Dish.Handle.CFrame = script.Parent.CookingSurface.CFrame:ToWorldSpace(CFrame.new(0,-0.15,0))
Dish.Parent = script.Parent
CookingStatus = false
FoodPresent = true
end
end
‘’’
Module:
function grillfunctions:Submit(player)
while grilltable.FoodCount ~= grilltable.FoodRequired do
local foods = self.Character:FindFirstChild("Tray").Foods:GetChildren()
local v = foods[#foods]
if v ~= nil then
if v:FindFirstChildWhichIsA("Attachment") ~= nil then
local rarity = v:FindFirstChildWhichIsA("Attachment").Name
if rarity then
local value = game.ReplicatedStorage.ExtraCoin:FindFirstChild(rarity).Value
grilltable.DishValue += value
end
end
v:destroy()
else
break
end
grilltable.FoodCount += 1
task.wait()
return
end
end
If I can’t find a solution, I’ll just redo the entire thing and read the documents again.
Maybe try this then?
local grillfunctions = {
["grilltable"] = {
FoodRequired = 5,
Cooked = 0,
FoodCount = 0,
DishValue = 0
}
}
-- code
return grillfunctions
and whatever how you are gonna use it, it would most likely be:
local grillfunctions = require("path")
grillfunctions.grilltable.ITEM
Try replacing:
function grillfunctions:Submit(player)
while grilltable.FoodCount ~= grilltable.FoodRequired do
local foods = self.Character:FindFirstChild("Tray").Foods:GetChildren()
local v = foods[#foods]
if v ~= nil then
if v:FindFirstChildWhichIsA("Attachment") ~= nil then
local rarity = v:FindFirstChildWhichIsA("Attachment").Name
if rarity then
local value = game.ReplicatedStorage.ExtraCoin:FindFirstChild(rarity).Value
grilltable.DishValue += value
end
end
v:destroy()
else
break
end
grilltable.FoodCount += 1
task.wait()
return
end
end
With:
function grillfunctions:Submit(player)
while grilltable.FoodCount ~= grilltable.FoodRequired do
local foods = player.Character:FindFirstChild("Tray").Foods:GetChildren()
local v = foods[#foods]
if v ~= nil then
if v:FindFirstChildWhichIsA("Attachment") ~= nil then
local rarity = v:FindFirstChildWhichIsA("Attachment").Name
if rarity then
local value = game.ReplicatedStorage.ExtraCoin:FindFirstChild(rarity).Value
grilltable.DishValue += value
end
end
v:destroy()
else
break
end
grilltable.FoodCount += 1
task.wait()
return
end
end
Same initial issue. I changed to your 2nd block, but retained the original for the script. Changing to the other version CookingFuncs:Submit(player) returned a “attempt to call missing method ‘Submit’ of table”
Returned nil for grilltable on the original script. I think there may be something wrong with my return.
In this version of the code you’re returning the grilltable but not the grillfunctions
The grilltable does not contain a :Submit method
I can’t return both grillfunctions and grilltable. Putting return grillfunctions in the functions still results in the same issue.
Try combining both tables into 1 table and then returning that table
I’m not sure if there is a way to combine functions that rely on my first table values to be in the same table as the keys of said values. I need the values to be in the original table as well so that they can be referred to from the original script.
Wait actually I forgot about variable names. I’ll try your way.