In short I have stringvalue’s inside a folder inside the player. There are imagebutton’s inside the playergui and I want to set those imagebutton’s names to the names of the stringvalue’s inside the player. The problem is that currently there are 4 imagebutton’s inside the player but 2 of those have the same name. One of them should have a 9 at the end becuase that is the missing one.
local Player = game.Players.LocalPlayer
local count = 0
for _,v in pairs(Player.PetInventory:GetChildren()) do
count = count + 1
end
local counter = 0
for i, petInInventory in pairs(Player.PetInventory:GetChildren()) do
for i, petInScrollingFrame in pairs(Player.PlayerGui.Inventory.Pets.ScrollingFrame:GetDescendants()) do
if petInScrollingFrame:IsA("ImageButton") then
if counter == count then
break
end
counter = counter + 1
print(counter)
if petInScrollingFrame.Name == petInInventory.Name then
else
newTemplate.Name = petInInventory.Name
end
end
end
end
Can you describe me a little bit more, I don’t understand what result are you trying to achieve? And for the first for loop with counter, you can instead, just use
#Player.PetInventory:GetChildren() -- "#" returns number of children in object