I was wondering if it was possible to select only one item from duplicates with the same name. For example I’m trying to make a pet equip system, where I find the pet’s equipped value in the Player’s Equipped folder. However if the player has multiple of the same pet, it would select all of those with the same. I was wondering if it was possible to select only one.
for i,v in pairs(EquippedFolder:GetChildren()) do
if Pet.Name == v.Name then
v.Parent = UnEquippedFolder
end
end
Make some sort of blacklist table for the names that have already been used. Then check if the pet name is in the table. Like so:
local checkedPets = {}
for i,v in pairs(EquippedFolder:GetChildren()) do
if Pet.Name == v.Name and not checkedPets[Pet.Name] then
v.Parent = UnEquippedFolder
table.insert(checkedPets, Pet.Name)
end
end
Wrote this on my phone so I’m not entirely sure if it’ll work for what you need.
That would break from the entire for loop. If I’m understanding his issue correctly, he wants to keep looping through all the equipped pets but only unequipping the first duplicate pet found.