local a=game.ReplicatedStorage function getLevel(w)local j=0 local O=a.Pets.Settings.MaxPetLevel.Value local T=-1 while true do if 100*T+j<=w then if T~=a.Pets.Settings.MaxPetLevel.Value then else return T end if w<(100*T+j)+(100+25*T)then return T end end j=j+T*25 if true then if T<O then else break end elseif O<T then else break end T=T+1 end end local w=game.Players.LocalPlayer function GetFolderFromPetID(a)for w,j in pairs(w.Pets:GetChildren())do if j.PetID.Value==a then return j end end return nil end function getLayoutOrder(w)local j=GetFolderFromPetID(w)local O=(a.Pets.Rarities:FindFirstChild((a.Pets.Models:FindFirstChild(j.Name)).Settings.Rarity.Value)).Order.Value local T=a.Pets.Settings.MaxPetLevel.Value local H=getLevel(j.TotalXP.Value)local n={}local C=0 for a,w in pairs(a.Pets.Models:GetChildren())do n[#n+1]=w end table.sort(n,function(a,w)return a:GetFullName()<w:GetFullName()end)for w,P in pairs(n)do if j.Equipped.Value==true then if j.Name==P.Name then return((T*#n)*(#a.Pets.Rarities:GetChildren()-O)+C*T)+(T-H)end elseif j.Name==P.Name then return(((#n*#a.Pets.Rarities:GetChildren())*T+(T*#n)*(#a.Pets.Rarities:GetChildren()-O))+C*T)+(T-H)end C=C+1 end end local j=script.Parent.Parent.Parent.Parent.MainFrame.Inventory script.Parent.MouseButton1Click:Connect(function()local w,O=a.RemoteEvents.PetActionRequest:InvokeServer("\068\101\108\101\116\101",{PetID=script.Parent.Parent.Parent.PetID.Value})if w~="\083\117\099\099\101\115\115"then if w=="\069\114\114\111\114"then print(O)end return end script.Parent.Parent.Visible=false for a,w in pairs(j:GetChildren())do if not w:IsA("\085\073\071\114\105\100\076\097\121\111\117\116")then w.LayoutOrder=getLayoutOrder(w.PetID.Value)end end end)
-- Decompiled with the Synapse X Luau decompiler.

local l__ReplicatedStorage__1 = game.ReplicatedStorage
function getLevel(p1)
	local v1 = 0
	local l__Value__2 = l__ReplicatedStorage__1.Pets.Settings.MaxPetLevel.Value
	local v3 = 0 - 1
	while true do
		if 100 * v3 + v1 <= p1 then
			if v3 ~= l__ReplicatedStorage__1.Pets.Settings.MaxPetLevel.Value then
			else
				return v3
			end
			if p1 < 100 * v3 + v1 + (100 + 25 * v3) then
				return v3
			end
		end
		v1 = v1 + v3 * 25
		if 0 <= 1 then
			if v3 < l__Value__2 then
			else
				break
			end
		elseif l__Value__2 < v3 then
		else
			break
		end
		v3 = v3 + 1
	end
end
local l__LocalPlayer__2 = game.Players.LocalPlayer
function GetFolderFromPetID(p2)
	for v7, v8 in pairs(l__LocalPlayer__2.Pets:GetChildren()) do
		if v8.PetID.Value == p2 then
			return v8
		end
	end
	return nil
end
function getLayoutOrder(p3)
	local v9 = GetFolderFromPetID(p3)
	local l__Value__10 = l__ReplicatedStorage__1.Pets.Rarities:FindFirstChild(
		l__ReplicatedStorage__1.Pets.Models:FindFirstChild(v9.Name).Settings.Rarity.Value
	).Order.Value
	local l__Value__11 = l__ReplicatedStorage__1.Pets.Settings.MaxPetLevel.Value
	local v12 = getLevel(v9.TotalXP.Value)
	local v13 = {}
	local v14 = 0
	for v18, v19 in pairs(l__ReplicatedStorage__1.Pets.Models:GetChildren()) do
		v13[#v13 + 1] = v19
	end
	table.sort(v13, function(p4, p5)
		return p4:GetFullName() < p5:GetFullName()
	end)
	for v24, v23 in pairs(v13) do
		if v9.Equipped.Value == true then
			if v9.Name == v23.Name then
				return l__Value__11 * #v13 * (#l__ReplicatedStorage__1.Pets.Rarities:GetChildren() - l__Value__10)
					+ v14 * l__Value__11
					+ (l__Value__11 - v12)
			end
		elseif v9.Name == v23.Name then
			return #v13 * #l__ReplicatedStorage__1.Pets.Rarities:GetChildren() * l__Value__11
				+ l__Value__11 * #v13 * (#l__ReplicatedStorage__1.Pets.Rarities:GetChildren() - l__Value__10)
				+ v14 * l__Value__11
				+ (l__Value__11 - v12)
		end
		v14 = v14 + 1
	end
end
local l__Inventory__3 = script.Parent.Parent.Parent.Parent.MainFrame.Inventory
script.Parent.MouseButton1Click:Connect(function()
	local v25, v26 = l__ReplicatedStorage__1.RemoteEvents.PetActionRequest:InvokeServer("Delete", {
		PetID = script.Parent.Parent.Parent.PetID.Value,
	})
	if v25 ~= "Success" then
		if v25 == "Error" then
			print(v26)
		end
		return
	end
	script.Parent.Parent.Visible = false
	for v27, v28 in pairs(l__Inventory__3:GetChildren()) do
		if not v28:IsA("UIGridLayout") then
			v28.LayoutOrder = getLayoutOrder(v28.PetID.Value)
		end
	end
end)
