Sorry to make another post, but this is pretty important to me. See- this crafting recipe script only works if the recipe has two ingredients at least to make a double ingredient recipe. But I need it to work for recipes that only have a single ingredient, any reason why it’s not working?
local Storage = game:GetService("ReplicatedStorage")
local Remote = Storage:WaitForChild("PestleEvent")
local Recipes = {
TestIngredient3 = {"Rotweed", "HarborBloom"}, -- Different Recipe
TestIngredient1 = {"HillLily"}, -- Different Recipe
}
local function pestleCraftIngredients(Player)
local inv = {}
local Backpack = Player.Backpack
for x, tool in pairs(Backpack:GetChildren()) do
table.insert(inv, tool.Name)
end
if #inv < 2 then
print("You need more items")
else
for x, tables in pairs(Recipes) do
if table.find(tables, inv[#inv-1]) and table.find(tables, inv[#inv]) then
for xx, toolToDelete in pairs(tables) do
Backpack[toolToDelete]:Destroy()
end
local item = Storage.MidCraftedIngredients[x]:Clone()
item.Parent = Backpack
break
end
end
end
end
Remote.OnServerEvent:Connect(pestleCraftIngredients)