Pet Inventory System

I have a egg hatching system, but I need a inventory so you can equip the pets. I have tried but when you equip one pet, it equips all pets with that name! I have tried turning the pets into an id system, but that causes its own errors. Mostly being it cant save!

--Pet inventory list
{
Equipped = "Dog";
Owned = {
"Dog"; --Both are equipped
"Cat";
"Dog"; --Both are equipped
}
}
--Pet inventory list with ID
{
Equipped = {"Dog",2}; --Pet egg script cant add the ids
Owned = {
{"Dog",1};
{"Cat",1};
{"Dog",2};
}
}
  1. I suggest making IDs for every pet with: os.time so you’ve the exact date they got them with it.
  2. Can you show us your whole script as the errors aren’t inside the “Owned” list.
  3. I suggest using:
    3.1. Have a UIGridLayour or a UITableLayout inside the ScreenGui.
-- this is the script for when you open your inventory
for index,petName in pairs(Owned) do
    local ImageButton = instance.new("ImageButton")
    --set the: ImageButton.Image, i suggest having a table with all the pets names and the pet images 
    --and looping through them until you find that petName == that name and setting the ImageButton.Image 
    ImageButton.Parent = PetInventory
    ImageButton.MouseButton1Click:Connect(function()
        -- give pet
    end)
end

I made it open and show all the pet. The problem is when you equip a pet it equips all pets of that type.

You should set the key to the specific dog type then.

So, instead of it being “Dog”, it should be, for example “Fluffy_GoldenDog_WithCollar” (to fit your solution) - or better, create a table with the Properties for your Dog type and use that instead.

The way I did it was every time you hatch a pet it would save to a folder inside the player,After that I would make a loop to get each pet from that folder(I need a loop to make it run forever to get any new pets)Make a :Instance("ViewportFrame) --this will be the gui that each will be in .
Next make it so every time a pet get hatches(Also check for the previous pets the player has owned)then make a new viewportframe each time to represent each pet,then parent the ui to the Pet Inventory frame.

Make sure to have a datastore to save all the players pets!