Help with adding pets into players' 'inventory'

Hello everyone, I am trying to make an inventory for pets that a player owns. I decided to save those pets to a folder parented to a player. But how would I loop through the folder and add a pet to the inventory UI, I’m sorry I’m not the best at explaining but for example the player has 3 pets, I could do something like

game.Player.PlayerAdded:Connect(function()
for number, pets do
--clone the pet ui to the mainframe
   end
end)

But I am not sure how to go around the player getting a new pet, since the function fires when the player joins. Does anyone know the best way to accomplish this?
Thanks!

game.Players.PlayerAdded:Connect(function(player)
    for i,v in pairs(playerPets) do
        local newPet = ReplicatedStorage:WaitForChild("Pets"):WaitForChild(v.Name):Clone()
        newPet.Parent = player:WaitForChild("Pets")
    end
end)

Essentially: loop through the pets you find saved and clone a new pet to their inventory folder.

In a separate script, you may want to check for pets being added to their inventory?

For example:

local petFolder = game.Players.LocalPlayer:WaitForChild("Pets")

petFolder.ChildAdded:Connect(function(child)
    -- new button etc.
end)
1 Like

Oh I didnt think of .ChildAdded
Thank you for your help!
Edit: It’s crazy how you got all of that right (by all of that I mean the variables.)
The ‘petFolder’ is right, the ‘ReplicatedStorage.Pets’ is also right