Pet system problem

So I started doing my pet system (only in my case the eggs drop items so it is a system of things), but I can not figure out how I do the second check, I explain here I have a local script, in the GUI

local rp = game:GetService("ReplicatedStorage")
local things = rp:WaitForChild("EggThings")
local eggs = workspace:WaitForChild("Eggs")


wait(3)

for i, v in	 pairs(eggs:GetChildren()) do
	local eggThings = things:FindFirstChild(v.Name)
	
	if eggThings ~= nil then
		
		local billboardTemp = script.Template:Clone()
		local container = billboardTemp:WaitForChild("Container")
		local container1 = container.Container1
		
		billboardTemp.Parent = script.Parent.Parent.EggBillboards
		billboardTemp.Name = v.Name
		billboardTemp.Adornee = v.Egg_1
		billboardTemp.Enabled = true
		
		for _, thing in pairs(eggThings:GetChildren()) do
			if thing.RarityString.Value == "Common" then
				if thing.RarityString.Value == "Rare" then
					print("container2")
					local clonedTemp2 = container.Container2:Clone()

					clonedTemp2.Name = thing.Name
					clonedTemp2.Rarity.Text = tostring(thing.Rarity.Value).. "%"
					clonedTemp2.Visible = true
					clonedTemp2.Parent = container
				end
				print("container1")
				local clonedTemp1 = container1:Clone()

				clonedTemp1.Name = thing.Name
				clonedTemp1.Rarity.Text = tostring(thing.Rarity.Value).. "%"
				clonedTemp1.Visible = true
				clonedTemp1.Parent = container
			end
		end
	end
end

But as you can see when I try to do a second check the rarity of the item it is not done, and comes out like this:

I explain, it chose the item common, but I need all the items of the whole rarity, from common, to mythic. But I don’t know how to check for all rarity? Here’s the guide I was doing:

I got confused when I first read what your issue was but the code is not detecting rarity because you aren’t doing elseif, you are putting a second if statement inside the first. I’ll explain the process of the code.

It first checks if it is common and only if it is common, then if it is common, it checks if it is rare.
Instead your code should look like this.

local eggs = workspace:WaitForChild("Eggs")


wait(3)

for i, v in	 pairs(eggs:GetChildren()) do
	local eggThings = things:FindFirstChild(v.Name)
	
	if eggThings ~= nil then
		
		local billboardTemp = script.Template:Clone()
		local container = billboardTemp:WaitForChild("Container")
		local container1 = container.Container1
		
		billboardTemp.Parent = script.Parent.Parent.EggBillboards
		billboardTemp.Name = v.Name
		billboardTemp.Adornee = v.Egg_1
		billboardTemp.Enabled = true
		
		for _, thing in pairs(eggThings:GetChildren()) do
			if thing.RarityString.Value == "Common" then
				print("container1")
				local clonedTemp1 = container1:Clone()

				clonedTemp1.Name = thing.Name
				clonedTemp1.Rarity.Text = tostring(thing.Rarity.Value).. "%"
				clonedTemp1.Visible = true
				clonedTemp1.Parent = container 
            elseif thing.RarityString.Value == "Rare" then
					print("container2")
					local clonedTemp2 = container.Container2:Clone()

					clonedTemp2.Name = thing.Name
					clonedTemp2.Rarity.Text = tostring(thing.Rarity.Value).. "%"
					clonedTemp2.Visible = true
					clonedTemp2.Parent = container
				end
			end
		end
	end
3 Likes

as FuneeDev says, your rare check never executes because it’s inside of your common check;. move it underneath this check, not inside