I have a folder located within the players backpack, designed for storing hats that you can then equip from a GUI. I don't know how to make it so when you leave, or reset, you keep the hats in the folder.... Can anyone help?
game:GetService("Players").PlayerRemoving:Connect(function(plr) for _, descendant in pairs(game:GetDescendants()) do if descendant.ClassName == "Folder" or descendant:IsA("PVInstance") then game:GetService("Debris"):AddItem(descendant, 0.1) -- Adds item to store end end end)
You should make a separate folder in the player and put the hats in there instead of putting the hats in Backpack. Everything in the Backpack gets removed when a player dies. You can also put the hats in StarterGear I think but I prefer a separate folder.
If you want to save the hats when the player leaves though, you’ll need to use something called DataStore, which is a bit more complicated than this.