what about you check if any children gets added to the player’s character which would be the accessory & make sure that it has that attribute so it wouldn’t save any accessory.
char.ChildAdded:Connect(function(child)
if child:IsA("Accessory") and child:GetAttribute("Item") then
-- Stores the Accessory
end
end)
well the thing is that im also adding groups, so i want to make sure that whatever type of item i do instead of being specific I can just guide the script by Name
oh i know, thats why i said i wanted to use names instead so basically even if its an accessory or a group as long as it has the specific name i want it will be selected, which is what i did for my other scripts
08:44:55.527 ServerScriptService.CharacterData:92: attempt to index nil with ‘GetDescendants’ - Server
game.Players.PlayerRemoving:Connect(function(plr)
local char = plr.Character
local playerUserId = plr.UserId
local accessorySave = {}
local inv = plr:FindFirstChild('Inventory')
for _,acc in pairs(inv:GetChildren()) do
table.insert(accessorySave, acc.Name)
end
local inv = plr:FindFirstChild('Inventory')
local characterSave = {}
for _,charS in pairs(char:GetDescendants()) do
for _,items in pairs(inv:GetChildren()) do
if charS.Name == items.Name then
table.insert(characterSave, charS.Name)
print(characterSave)
end
end
end
local success, errorMessage = pcall(function()
contributorDS:SetAsync("UserInventory-"..player.UserId, characterSave, accessorySave) --Save
end)
end)