Correct me if I’m wrong, but I think I found a way to find a specific object with specifications from the same local. It occurred to me that maybe putting parentheses could be possible, since the system gets confused and points out the problem if you don’t put parentheses, but apparently with the parentheses it doesn’t mark the error.
local asd = (Backpack:FindFirstChild(Slot.Name) and Backpack[Slot.Name]:GetAttribute("Type_Tool") == Slot:GetAttribute("Type_Tool"))
if asd then
asd.Stack.Value = asd.Stack.Value +1
if not ToolsFolder.FoodIngredients:FindFirstChild(Slot.Name) then return end
local Found_tool = ToolsFolder.FoodIngredients[Slot.Name]:Clone()
Found_tool:WaitForChild("Stack").Value = 1
Found_tool.Parent = Backpack
The FindFirstChild is used to determine if it exists, and if it exists it does the rest, which is to find if the other object has the same attribute as the other. I do not know if I am correct, or if it works and in the future it will give me possible errors.
Well, there will be many tools and all the tools will be saved. I am wanting to optimize as much as possible (both with tools, models and scripts), with models in blender, with shortening scripts, with the tools it will be differentiated with the attributes (an example is own ax and work ax, I use the attributes to differentiate them and thus not having free tools).