Hey, my script doesn’t work, I’m trying to make it include more than one recipe in a single function (because i don’t want to deal with multiple scripts for a single recipe… I mean I could but I really prefer it be in a single script) it just checks player’s tools from a certain “recipe” table, and turns it into one tool but it’s clearly not working, I need help
local Storage = game.ReplicatedStorage
local Remote = Storage.PestleEvent
local Recipes = {
MakeMidIngredients1 = {Requirement = "StarterIngredient1", "StarterIngredient2", Amount = 1};
MakeMidIngredients2 = {Requirement = "StarterIngredient2", "StarterIngredient3", Amount = 1};
MakeMidIngredients3 = {Requirement = "StarterIngredient1", "StarterIngredient3", Amount = 1};
}
local ToolsPlacedInto = {}
local function pestleCraftIngredients(Player)
print("SERVER: Pestle Craft called by", Player)
local Backpack = Player.Backpack
local Character = Player.Character
local Count = 0
--craft the first recipe below vvv
for _, Tool in pairs(Backpack:GetChildren()) do
local MakeMid1 = Recipes.MakeMidIngredients1 -- To make the Mid ingredient(s)
if Tool.Name == MakeMid1.Requirement then
if #MakeMid1 < MakeMid1.Amount then
table.insert(ToolsPlacedInto, Tool)
end
end
if Count == #Recipes then
Storage.MidCraftedIngredients.MidIngredient1:Clone().Parent = Backpack
break
end
for _, Tool in next, Character:GetChildren() do
if Tool.Name == Tool then
table.insert(ToolsPlacedInto, Tool)
Count += 1
end
if Count == #Recipes then
Storage.MidCraftedIngredients.MidIngredient1:Clone().Parent = Backpack
break
end
end
if #MakeMid1+1 == MakeMid1.Amount then
if Count == #Recipes then
for _,v in next, ToolsPlacedInto do
v:Destroy()
end
end
end
end -- ends that recipe crafting
-- make another recipe here?
end
Remote.OnServerEvent:Connect(pestleCraftIngredients)