Hello developers!
I want to sort pets from the highest % to the lowest % but when 2 pets have the same % then script display x2.
This is how it looks:
Script:
for i, v in pairs(Eggs:GetChildren()) do
local eggPets = Pets:FindFirstChild(v.Name)
if eggPets ~= nil then
local bilboardTemp = script.Template:Clone()
local container = bilboardTemp:WaitForChild("Container")
local MainFrame = container:WaitForChild("MainFrame")
local Template = MainFrame:WaitForChild("Template")
local Display = Template:WaitForChild("Display")
bilboardTemp.Parent = script.Parent.Parent.EggBilboards
bilboardTemp.Name = v.Name
bilboardTemp.Adornee = v.DisplayPet
bilboardTemp.Enabled = true
container.Price.Text = "⚡"..v.Price.Value
local pets = {}
for x, pet in pairs(eggPets:GetChildren()) do
table.insert(pets, pet.Rarity.Value)
end
local sort = table.sort(pets, function(a, b)
return a > b
end)
for _, rarity in pairs(pets) do
for _, pet in pairs(eggPets:GetChildren()) do
if pet.Rarity.Value == rarity then
local rarity = pet.Rarity.Value
local clonedTemp = Template:Clone()
clonedTemp.Name = pet.Name
clonedTemp.Rarity.Text = tostring(pet.Rarity.Value).."%"
clonedTemp.Visible = true
clonedTemp.Parent = MainFrame
local petModule = module3d:Attach3D(clonedTemp.Display,pet:Clone())
petModule:SetDepthMultiplier(1.2)
petModule.Camera.FieldOfView = 5
petModule.Visible = true
runService.RenderStepped:Connect(function()
petModule:SetCFrame(CFrame.Angles(0,-5,0) * CFrame.Angles(math.rad(-10),0,0))
end)
end
end
end
end
end