How would I load equipped pets?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")

local player = game.Players.LocalPlayer

local Module3D = require(ReplicatedStorage:WaitForChild("Module3D"))

local frame = script.Parent
local info = frame.Info
local displayPet = info.DisplayPet
local scrollFrame = frame.ScrollingFrame
local template = scrollFrame.Template
local closeButton = frame.CloseButton
local petNameDisplay = info.PetName
local equipButton = info.Equip
local unequipAll = frame.UnequipAll


local selectedTemplate = nil 
closeButton.Activated:Connect(function() frame.Parent.Enabled = false end)


local function onEquip()
	
	if selectedTemplate ~= nil then
		if selectedTemplate:FindFirstChild("Equipped").Value == false then
			local result = ReplicatedStorage.Remotes.EquipPet:InvokeServer(selectedTemplate.Name)

			if result == "Equip" then
				selectedTemplate.Checkmark.Visible = true
				equipButton.Text = "Unequip"
				selectedTemplate:FindFirstChild("Equipped").Value = true
			else -- if the player already has max pets(make an error screen)
				
			end
		else
			local result = ReplicatedStorage.Remotes.UnequipPet:InvokeServer(selectedTemplate.Name)

			if result == true then
				selectedTemplate.Checkmark.Visible = false
				equipButton.Text = "Equip"
				selectedTemplate:FindFirstChild("Equipped").Value = false
			end
		end
	end
end


_G.newTemplate = function(petName)
	local newTemplate = template:Clone()
	newTemplate.Name = petName
	newTemplate.Visible = true
	newTemplate.Parent = scrollFrame

	local petModel = Module3D:Attach3D(newTemplate.Display,ReplicatedStorage.Pets:FindFirstChild(petName,true):Clone())
	petModel:SetDepthMultiplier(1)
	petModel.Camera.FieldOfView = 5
	petModel.Visible = true

	RunService.RenderStepped:Connect(function()
		petModel:SetCFrame(CFrame.Angles(0,0.1,0) * CFrame.Angles(math.rad(-10),0,0))
	end)
	newTemplate.Activated:Connect(function()
		onTemplatePress(newTemplate)
	end)
end

equipButton.Activated:Connect(function() onEquip() end)

unequipAll.MouseButton1Click:Connect(function()
	for i, v in pairs(scrollFrame:GetChildren()) do
		if v:IsA("TextButton") then
			v:FindFirstChild("Equipped").Value = false
			v.Checkmark.Visible = false
			ReplicatedStorage.Remotes.UnequipAll:FireServer() 
		end
	end
end)

player.CharacterAdded:Wait()
wait(2)
--This is after it loads
for i, v in pairs(player.OtherStats.Pets:GetChildren()) do
	_G.newTemplate(v.Name)
end

How can I use/alter these functions so that it loads equipped pets?

I’m Confused… What exactly is the problem here? You’ve shown a script and asked for how you want something to be done, You should be more specific instead. For example:
My Code works like this, It Achieves a + b + c, However i want it to also achieve this behaviour, This behaviour works like in the example below, Any ideas on how to achieve this?