Module script, function assistance needed

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.

1 Like

You can also try storing the tables into separate modules if you prefer

It all results into the same issue of Submit is not a valid member of Player “Players.tz_ow” . I think I’ll just have to redo the entire part and try to figure out what went wrong. Will be a learning process for me again as well since I do lack experience in handling modulescripts. Thanks for your help. I appreciate everyone who attempted as well.

1 Like

No, instead of doing player:Submit() do grillfunctions:Submit(player) and pass the player as a parameter. That should work.