why isnt player:Submit() working? 1st picture is a module script, 2nd is in a script
By not working, what do you mean? Are you getting any errors in your output? If not, then please explain in detail what your problem is
Also, it’s much better to paste your code between triple backsticks like in the example I wrote below instead of screenshotting it
```lua
print(“Hello, world!”)
```
Sure. Intent is to check for extra bonuses from intvalues which are children of the attachment that also have a particle effect. Idea is to reward for more rarer drops and to store it in DishValue key part of grilltable table.
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
Script:
if player.Character.Tray.Foods:GetChildren() ~= nil then
player:Submit()
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
You need to do a bit workaround by making it possible to use your own methods. I recommend this tutorial
Hello, it seems you’re calling :Submit() onto a presumed “Player Instance”, and not on the Selected Module which seems to be causing you’re error, I’m unfamiliar if this was you’re intent, or you want this to be the case and work as such.
We’ll need to see the contents of the script for the workspace.Grill to help identify the cause of the error, please
The method needs to connect to the player. If I connect to the module, it wouldn’t work because the intention is to get an attachment. I used the other way which is to do module:method(parameter) in this case, would be CookingFuncs:Submit(player).
Returned this in output.
This is the entire module script. I already have a working version of the original script without the use of modulescripts. I’m trying to use modulescripts to make a new version that is easier to read.
local grilltable = {
FoodRequired = 5,
Cooked = 0,
FoodCount = 0,
DishValue = 0
}
local grillfunctions = {}
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(self)
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
Hello, it would be advised to add
return grillfunctions
at the end of your Module, otherwise it won’t return any functions, as I see its not present in the script.
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.