Hopefully I used the right phrasing and stuff in the title.
How would I be able to check for multiple dictionary values in a table? I can’t switch to an array because I need to check if the player has certain values’ names that correlate to the keys within the table, as well as their values matching the number defined by each key before making the script give it the “all good” (hopefully that makes sense?)
local CraftingRecipes = {
["Part3"] = {
[1] = { --don't pay any mind to this, this will be for an alternate recipe system i will tackle in the future
["Part1"] = 1;
["Part2"] = 2;
};
};
return CraftingRecipes
If you couldn’t tell by now, I’m trying to achieve a crafting system.
This is the current (mess of an) attempt I’ve made at achieving what I want in the title, but it it will print if only one of the required items is in the “Inventory” folder (which is created via a script in ServerScriptService)
for craftableItem,v1 in pairs(CraftingRecipes) do --gets all the recipes
for i,v2 in ipairs(v1) do
for material1,v3 in pairs(v2) do
if Player.Inventory:FindFirstChild(material1) then
print(craftableItem)
for index,v4 in pairs(CraftingRecipes[craftableItem]) do
for requiredMaterial,amount in pairs(v4) do
if Player.Inventory:FindFirstChild(requiredMaterial) then
if Player.Inventory:FindFirstChild(requiredMaterial).Value >= amount then
print(requiredMaterial)
else
break
end
else
break
end
end
end
end
end
end
end
Hopefully I’ve provided enough information, I’m completely and utterly stumped and it’s extremely frustrating trying a plethora of different things without ever reaching the intended result (only printing when the player has both values). The script I’ve used is intended to show what crafting recipes are available (much like Terraria’s), but any scripting help will most likely be applicable to the actual crafting system as well.
Anyways, any help will be greatly appreciated!