local y=function(y)local c=require(rep.Modules.Pet.RealPetName)return c.GetRealPetName(y)end local c=function(c,T,F,E)if F=="\080\101\116"then local F=y(tostring(T))if E~=nil then if E.Parent then if E.Parent:FindFirstChild(F)then return true end end else if c.Index:FindFirstChild(F)then return true end end end return false end module.AddPetToIndex=function(T,F,E,H)if T and F~=nil then local l=c(T,F,E,H)if l==false then local c=y(tostring(F))local E=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")E.Name=tostring(c)E.Value=tostring(c)if H~=nil then if H.Parent then E.Parent=H.Parent else E.Parent=T.Index end else E.Parent=T.Index end return true end end end module.LoadIndex=function(y,c,T)for c,F in pairs(c)do for c,F in pairs(F)do module.AddPetToIndex(y,F,"\080\101\116",{Parent=T})end end end return module
-- Get Real Pet Name --
local getPetName = function(name)
	local realPetNameMod = require(rep.Modules.Pet.RealPetName)
	return realPetNameMod.GetRealPetName(name)
end

local checkIfInIndex = function(plr, beginPetName, which, params)
	if which == "Pet" then
		local petName = getPetName(tostring(beginPetName))
		if params ~= nil then
			if params.Parent then
				if params.Parent:FindFirstChild(petName) then
					return true
				end
			end
		else
			if plr.Index:FindFirstChild(petName) then
				return true
			end
		end
	end
	return false
end

module.AddPetToIndex = function(plr, beginPetName, which, params)
	if plr and beginPetName ~= nil then
		local isInIndex = checkIfInIndex(plr, beginPetName, which, params)
		if isInIndex == false then
			local petName = getPetName(tostring(beginPetName))
			local petIndex = Instance.new("StringValue")
			petIndex.Name = tostring(petName)
			petIndex.Value = tostring(petName)
			if params ~= nil then
				if params.Parent then
					petIndex.Parent = params.Parent
				else
					petIndex.Parent = plr.Index
				end
			else
				petIndex.Parent = plr.Index
			end
			return true
		end
	end
end

module.LoadIndex = function(plr, tbl, parent)
	for _, v in pairs(tbl) do
		for _, petName in pairs(v) do
			module.AddPetToIndex(plr, petName, "Pet", { Parent = parent })
		end
	end
end

return module
