How Can I Make a Pet Save System

:thinking: How Can I Make a Pet Recording System Looks Like This:

Screenshot_1

mytest script :

local DTS = game:GetService("DataStoreService")
local PetDatas = DTS:GetDataStore("PetValuesDatasssss")
local PetsModule = require(game.ReplicatedStorage.PetModule)
local PlrPetInventory

local function saveData(player)
    local PetInventory = {}

    local PlrPetInventory = {}

    local UnlockedPets = player:FindFirstChild("Pets")
    

   for i1,v1 in pairs(UnlockedPets:GetChildren()) do
        local newpettab = {[v1.Name] = {}}
        local petbase = newpettab[v1.Name]
        for i2,v2 in pairs(v1:GetChildren()) do
            if v2:IsA("ValueBase") then
                local newvaltoadd = {[v2.Name] = v2.Value}
                table.insert(petbase,newvaltoadd)
            end
        end
        table.insert(PetInventory,newpettab)
    end

    local success, errorMessage = pcall(function()
        PetDatas:SetAsync(player.UserId.."-pet", PetInventory)
    end)

    if success then
        print("Data Saved.")
    else
        print("Error: "..errorMessage)
    end
end

game.Players.PlayerAdded:Connect(function(player)
    local PetsFolder = Instance.new("Folder",player)
    PetsFolder.Name = "Pets"
    
    local EquippedValue = Instance.new("BoolValue",PetsFolder)
    EquippedValue.Name = "Equipped"
    
    local PetIDValue = Instance.new("StringValue",PetsFolder)
    PetIDValue.Name = "PetID"
    
    local RaritieValue = Instance.new("StringValue",PetsFolder)
    RaritieValue.Name = "Raritie"
    
    local CoinMultipier = Instance.new("NumberValue",PetsFolder)
    CoinMultipier.Name = "CoinMultipier"
    
    local success,errorMessage = pcall(function()
        PetDatas:GetAsync(player.UserId.."-pet")
    end
    local ht = game:GetService("HttpService")
    local enc1 = ht:JSONEncode(errorMessage)
    print(enc1)
    if success then
        
        if errorMessage then
            for i, v in pairs(data) do
                print(v)
                if PetsModule.PetSystemPets[v] then
                    local newPetFolder = Instance.new("Folder",PetsFolder)
                    newPetFolder.Name = v
                    
                    game.ReplicatedStorage.Pets.LoadClient:FireClient(player,data)
                else
                    print("Your Pet Value Not Working.")
                end
            end
        else
            print("U No Have Pets!")
        end
        
        print("Data Loaded.")
    else
        print("Error: "..errorMessage)
    end
end)


game.Players.PlayerRemoving:Connect(function(player)
    saveData(player)
end)

game:BindToClose(function()
    for i, v in pairs(game.Players:GetPlayers()) do
        saveData(v)
    end
end)

make 2 more values named amt and Has
amt should be the amount of the same type of pet you have
Has = if you atleast got 1 amt then your pet will be shown
and make it save the 2 values so when ever you join it saves the pet amount and the actual pet