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[2].Name) and Backpack[Slot[2].Name]:GetAttribute("Type_Tool") == Slot[2]:GetAttribute("Type_Tool"))
if asd then
asd.Stack.Value = asd.Stack.Value +1
else
if not ToolsFolder.FoodIngredients:FindFirstChild(Slot[2].Name) then return end
local Found_tool = ToolsFolder.FoodIngredients[Slot[2].Name]:Clone()
Found_tool:WaitForChild("Stack").Value = 1
Found_tool.Parent = Backpack
end
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.
I finally discovered this, now I will be able to optimize the scripts more. Before I used loops to find them and it worked, but this is better for optimization.
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).