Index System Help

local child = game:GetService("Workspace").Eggs:GetChildren()
local RS = game.ReplicatedStorage
local Library = RS.Pets
local Eggs = require(Library:WaitForChild("Eggs"))
local plr = game.Players.LocalPlayer
local rarities = {[1] = {"Common"},[2] = {"Rare"}}

for i, v in pairs(game:GetService("Workspace").Eggs:GetChildren()) do
	local new = script.Parent.Parent:WaitForChild("IndexClone").Frame:Clone()
	new.Parent = script.Parent.Frame
	new.TextLabel.Text = tostring(v.Name)
	new.Name = v.Name
	
	
	for i, v in pairs(Eggs[v.Name]["Pets"]) do
		print(v.Name)
		local petClone = new.Frame.Frame:Clone()
		petClone.Parent = new.Frame
		petClone.Visible = true
		--petClone.PetName.Text = v.Name
		petClone.Name = v.Name
		local ModelClone = game.ReplicatedStorage.Pets.Models:WaitForChild(v.Name).Normal:Clone()
		local Pos = ModelClone.PrimaryPart.Position
		local camera = Instance.new("Camera")
		
		petClone.ViewportFrame.CurrentCamera = camera
		ModelClone.Parent = petClone.ViewportFrame
		camera.CFrame = CFrame.new(Vector3.new(Pos.X + 2.25, Pos.Y, Pos.Z + 1), Pos)
	end
	
	
	
end

while wait() do
	for i, egg in pairs(game:GetService("Workspace").Eggs:GetChildren()) do
		for i, pets in pairs(Eggs[egg.Name]["Pets"]) do
			for i, owned in pairs(plr:WaitForChild(plr.Name):GetChildren()) do
				if owned.Name == pets.Name then
					local eggHolder = script.Parent.Frame:WaitForChild(egg.Name)
					eggHolder.Frame:WaitForChild(pets.Name).ViewportFrame.ImageColor3 = Color3.fromRGB(255, 255, 255)
					
				else
					local eggHolder = script.Parent.Frame:WaitForChild(egg.Name)
					eggHolder.Frame:WaitForChild(pets.Name).ViewportFrame.ImageColor3 = Color3.fromRGB(0, 0, 0)
				
				end
			end
		end
	end
	
end

Can someone please help. I am making an index and the problem is that it only loops once and not everything

Could I please have more information about the problem?

If you watch the video once you hatch a new egg it goes back to dark cause it’s only looping once.

Is there only 1 child in game.Workspace.Eggs?
Is there only 1 child in plr?

No there are 3 childs and there are multiple childs in player

	for i, egg in pairs(game:GetService("Workspace").Eggs:GetChildren()) do
		for i, pets in pairs(Eggs[egg.Name]["Pets"]) do
			for i, owned in pairs(plr:WaitForChild(plr.Name):GetChildren()) do
				if owned.Name == pets.Name then
					local eggHolder = script.Parent.Frame:WaitForChild(egg.Name)
					eggHolder.Frame:WaitForChild(pets.Name).ViewportFrame.ImageColor3 = Color3.fromRGB(255, 255, 255)
					
				else
					local eggHolder = script.Parent.Frame:WaitForChild(egg.Name)
					eggHolder.Frame:WaitForChild(pets.Name).ViewportFrame.ImageColor3 = Color3.fromRGB(0, 0, 0)
				
				end
			end
		end
	end
	
end

this is the part that is not working properly

So all the owned pets are inside a folder inside the player that has the same name as the player? I am confused :confused:

Yeah so I accidently made a folder called player.Name so yeah. Sorry if that sounds confusing

So if I played the game, the folder would be called Vorexted, correct? Just clearing up that you didn’t make a typo. Then I will look through it more.

yes thats how it would be. :slight_smile:

Ok, so you say the issue is that it only “loops once”? Can you explain more.

yeah so basicly if I hatch a egg a string value is added which stores everything you have hatched. And basicly Each time you hatch something it should be able to determine if the folder string value is also “pets.Name”. Problem is when you hatch the other viewport frame that WAS NOT BLACK turned black

Wait nvm I fixed it by making vewport frame image color 3 black first and deleted else statement.

1 Like

That is great. I just have an “owned” folder that I use for my pet index. Also, by any chance, are you using a pet system you found somewhere? It seems oddly familiar to something a friend of mine made just wondering :smile: Good luck!

Yeah I am using once called Agent Pet System for now. Basicly my friend is making his own game and doesn’t really know how to script so I just made one for him and he is using the same one

1 Like

Yeah that was made by my friend AgentCandyPenguin. Nice lol :smile:

1 Like

Hey, do you know how to use this system. Only because I need some help because I did everything I need to but when I go to open the egg nothing happens as no index pops up, I cannot open an egg or anything.

I do not know what I am doing wrong sorry, it might be something it is in the wrong place but I am not sure.

Thanks,