Sure, I’ll show you the codes and explain. Hope it helps.
But first, these folders are added to the player when they join a game, just to make things clear.
And the GUI looks like this
(I’m using screenshots because I realized the forums was doing weird things to my code by splitting stuff ‘wrongly’)
First Script(ItemInventoryCheck), ServerScriptService
What this does is look through every child from a folder(ItemInventory), and update values depending on the information inside said child.
If a folder’s(child’s) “itemName…Number” value is 0, the folder gets deleted, pretty straight foward.
Second Script(EquipItem), Gui’s LocalScript
The script waits for the player to press the equip button, which creates a new int value. The name is the item and the value is the backpack hotkey(which I can’t work on rn cuz of this weird bug) and parents it to the “EquippedBackpack”. So, the child should already be inside the folder and actually be a child of the folder. Unlike the issue I’m having…
Third Script(AssignTools), ServerScriptService
It waits until a child(folder) of ItemInventory(or any other inventory folder) is removed, then calls a function which checks to see if any of the existing int values’ names inside “EquippedBackpack” have a correspoding folder in any of the inventories with the same name. If there is no folder with the same name, it destroys the int value.
Except, it hasn’t even got there yet, being stuck at the part where
and this pretty annoying as there are no errors, the int value is just there sitting in the folder, and it’s not finding anything.
Before
Destroying the items
After
Even though the script(s) know the folder is gone, therefore deleting the button, it can’t find the int value inside EquippedInventory, which is weird unless there’s something I don’t understand. Not even ChatGPT can solve this one, not with a 3 hour talk of going around in circles.
Another thing I tried was including the in deletion part inside the First Script and just destroy() everything relevant when itemNumber == 0, which was actullaly the original idea, but same thing happened.
I think I’ll go ahead and make some other visual things since I can’t really continue the codes with this block in the way.